 
 GO
 
-/****** Object:  StoredProcedure [dbo].[Company_Delete]    Script Date: 5/23/2017 5:21:28 PM ******/
-
-SET ANSI_NULLS ON
-
-GO
-
-SET QUOTED_IDENTIFIER ON
-
-GO
-
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Company_Delete]') AND type in (N'P', N'PC'))
-
-BEGIN
-
-EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[Company_Delete] AS' 
-
-END
-
-GO
-
-
-
-ALTER PROCEDURE [dbo].[Company_Delete]
+/****** Object:  StoredProcedure [dbo].[Company_Delete]    Script Date: 6/5/2017 5:22:06 PM ******/
+
+SET ANSI_NULLS ON
+
+GO
+
+SET QUOTED_IDENTIFIER ON
+
+GO
+
+
+
+CREATE PROCEDURE [dbo].[Company_Delete]
 
 @Id INT 
 


) ON [PRIMARY]

END

GO

/****** Object:  Table [dbo].[AspNetUsers]    Script Date: 5/23/2017 5:21:28 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNetUsers]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[AspNetUsers](

	[Id] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

	[Email] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

	[EmailConfirmed] [bit] NOT NULL,

	[PasswordHash] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

	[SecurityStamp] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

	[PhoneNumber] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

	[PhoneNumberConfirmed] [bit] NOT NULL,



GO

/****** Object:  StoredProcedure [dbo].[Offer_Add]    Script Date: 6/5/2017 5:22:06 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO





CREATE PROCEDURE [dbo].[Offer_Add]

@Id INT OUTPUT,

@Title NVARCHAR(100),

@CompanyId INT OUTPUT,

@Description NVARCHAR(MAX) NULL,

@Url NVARCHAR(200) NULL,

@Category NVARCHAR(128) NULL



AS



SET NOCOUNT ON;



INSERT INTO Offer 

(Title ,CreatedOn, CompanyId, Description, Url, Category)

VALUES 

(

@Title,

GETDATE(),

@CompanyId,

@Description,

@Url,

@Category

 )



SET @Id = @@IDENTITY



RETURN

GO

/****** Object:  StoredProcedure [dbo].[Offer_Delete]    Script Date: 6/5/2017 5:22:06 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



CREATE PROCEDURE [dbo].[Offer_Delete]

@Id INT 



AS



SET NOCOUNT ON;

DELETE Offer

WHERE ID = @ID





RETURN

GO

/****** Object:  StoredProcedure [dbo].[Offer_Get]    Script Date: 6/5/2017 5:22:06 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



CREATE PROCEDURE [dbo].[Offer_Get]

@Id INT 



AS



SET NOCOUNT ON;

SELECT * FROM Offer

WHERE ID = @ID





RETURN

GO

/****** Object:  StoredProcedure [dbo].[Offer_GetAll]    Script Date: 6/5/2017 5:22:06 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



CREATE PROCEDURE [dbo].[Offer_GetAll]

@CompanyId INT



AS



SET NOCOUNT ON;

SELECT * FROM Offer

WHERE CompanyId = @CompanyId









RETURN

GO

/****** Object:  StoredProcedure [dbo].[Offer_GetByCompanyId]    Script Date: 6/5/2017 5:22:06 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



CREATE PROCEDURE [dbo].[Offer_GetByCompanyId]

@CompanyId INT 



AS



SET NOCOUNT ON;

SELECT * FROM Offer 

WHERE CompanyId = @CompanyId





RETURN

GO

/****** Object:  StoredProcedure [dbo].[Offer_Update]    Script Date: 6/5/2017 5:22:06 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



CREATE PROCEDURE [dbo].[Offer_Update]

@Id INT,

@Title NVARCHAR(100),

@Description NVARCHAR(MAX) NULL,

@Url NVARCHAR(200) NULL,

@Category NVARCHAR(128) NULL



AS



SET NOCOUNT ON;

UPDATE Offer

SET

	Title = @Title,

	UpdatedOn = GETDATE(),

	Description = @Description,

	Url = @Url,

	Category = @Category

WHERE Id = @Id





RETURN

GO

ALTER DATABASE [CD_Test] SET  READ_WRITE 

GO

