public int InsertTax(TaxModel taxModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("Tax", "TaxName", taxModel.TaxName, taxModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("Tax"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO Tax (Id,TaxName,TaxPercentage,TaxType," + "UserIdInserted,DateInserted,IsDeleted)" + "VALUES (" + MaxId + ",@TaxName,@TaxPercentage,@TaxType," + +LoginInfo.Userid + ",GetUtcDate(),0); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, taxModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("Tax"); } else { sqltrans.Rollback(); } return(result); } }
public int InsertPaymentMethod(PaymentMethodModel PaymentMethodModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("PaymentMethod", "PaymentMethodName", PaymentMethodModel.PaymentMethodName, PaymentMethodModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("PaymentMethod"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO PaymentMethod (Id,PaymentMethodName,IsBank,IsIntegration,IsActive)" + "VALUES (" + MaxId + ",@PaymentMethodName, @IsBank,@IsIntegration,@IsActive); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, PaymentMethodModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("PaymentMethod"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertCardTerminal(CardTerminalModel cardTerminalModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); int MaxId = commonRepository.GetMaxId("CardTerminal"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO CardTerminal (Id, CardTerminalName," + "OutletId, " + "IsActive)" + "VALUES (" + MaxId + ",@CardTerminalName," + "@OutletId," + "@IsActive); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, cardTerminalModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(result); }
public int InsertTables(TablesModel TablesModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { TablesModel.Status = (TablesModel.Status == 0) ? null : TablesModel.Status; CommonRepository commonRepository = new CommonRepository(_ConnectionString); int MaxId = commonRepository.GetMaxId("Tables"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO Tables (Id,TableName,OutletId,PersonCapacity,TableIcon,Status,IsActive)" + "VALUES ( " + MaxId + ",@TableName,@OutletId,@PersonCapacity,@TableIcon,@Status,@IsActive);" + " SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, TablesModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("Tables"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertVarient(VarientModel varientModel) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); int MaxId = commonRepository.GetMaxId("Varient"); int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO Varient (Id,VarientName,FoodMenuId," + "Price, " + "IsActive)" + "VALUES (" + MaxId + ",@VarientName,@FoodMenuId," + "@Price," + "@IsActive); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, varientModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("Varient"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertFoodMenu(FoodMenuModel foodMenuModel) { int result = 0; int detailsResult = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("FoodMenu", "FoodMenuName", foodMenuModel.FoodMenuName, foodMenuModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("FoodMenu"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO FoodMenu " + "( Id,FoodCategoryId, FoodMenuName, FoodMenuType,FoodMenuCode, FoodMenuBarCode,PurchasePrice,SalesPrice, Notes, UnitsId,FoodVatTaxId," + " Position, IsActive) " + "Values " + "(" + MaxId + ", @FoodCategoryId, upper(@FoodMenuName),@FoodMenuType, @FoodMenuCode, @FoodMenuBarCode,@PurchasePrice,@SalesPrice, @Notes,@UnitsId,@FoodVatTaxId," + "@Position, @IsActive);" + " SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, foodMenuModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); //CREATE ENTRY INTO INVETORY AS STOCK 0.00 query = " INSERT INTO INVENTORY (STOREID,FOODMENUID,STOCKQTY,USERIDINSERTED,ISDELETED)" + " Select S.ID as StoreId,FM.Id,0,1,0 from foodmenu FM CROSS JOIN STORE S " + " WHERE FM.ID =" + MaxId; result = con.Execute(query, foodMenuModel, sqltrans, 0, System.Data.CommandType.Text); //CREATE ENTRY INTO FOODMENURATE query = " INSERT INTO FOODMENURATE(Id, OutletId, FoodMenuId, SalesPrice, FoodVatTaxId, IsActive) " + " Select(select max(Id) from foodmenurate) + ROW_NUMBER() OVER(ORDER BY fm.id desc) AS Row# " + " , O.Id,FM.Id,FM.SalesPrice,FM.FoodVatTaxId,1 from FoodMenu FM Cross join Outlet O " + " Where FM.Id =" + MaxId; result = con.Execute(query, foodMenuModel, sqltrans, 0, System.Data.CommandType.Text); string output = commonRepository.SyncTableStatus("FoodMenu"); output = commonRepository.SyncTableStatus("INVENTORY"); output = commonRepository.SyncTableStatus("FOODMENURATE"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertOutlet(OutletModel outletModel) { int result = 0, storeCount = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("Outlet", "OutletName", outletModel.OutletName, outletModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("Outlet"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var queryStoreCount = "select count(storeId) from Outlet where IsActive=1 And IsDeleted=0 And storeId=" + outletModel.StoreId; storeCount = con.QueryFirstOrDefault <int>(queryStoreCount, null, sqltrans); if (storeCount == 0) { var query = "INSERT INTO Outlet" + "(Id,StoreId, OutletName, OutletAddress1, OutletAddress2, OutletPhone, OutletEmail," + " InvoiceHeader, InvoiceFooter, IsCollectTax, IsPreorPostPayment, IsActive, IsLock)" + "VALUES " + "(" + MaxId + ", @StoreId, @OutletName, @OutletAddress1, @OutletAddress2, @OutletPhone, @OutletEmail, " + "@InvoiceHeader, @InvoiceFooter, @IsCollectTax, @IsPreorPostPayment, @IsActive, @IsLock); " + " SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, outletModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); //CREATE ENTRY INTO FOODMENURATE query = " INSERT INTO FOODMENURATE(Id, OutletId, FoodMenuId, SalesPrice, FoodVatTaxId, IsActive) " + " Select(select max(Id) from foodmenurate) + ROW_NUMBER() OVER(ORDER BY fm.id desc) AS Row# , " + MaxId + ", FM.Id,FM.SalesPrice,FM.FoodVatTaxId,1 FROM FoodMenu FM WHERE isdeleted = 0 "; result = con.Execute(query, outletModel, sqltrans, 0, System.Data.CommandType.Text); string output = commonRepository.SyncTableStatus("Outlet"); output = commonRepository.SyncTableStatus("FOODMENURATE"); } else { sqltrans.Rollback(); } } else { result = -1; } } return(result); }
public int InsertIngredient(IngredientModel ingredientModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("Ingredient", "IngredientName", ingredientModel.IngredientName, ingredientModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("Ingredient"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT into Ingredient(Id,IngredientName," + "Code, " + "IngredientCategoryId," + "IngredientUnitId," + "PurchasePrice," + "SalesPrice," + "AlterQty," + "TaxId," + "IsActive) " + "VALUES(" + MaxId + ",@IngredientName," + " @Code," + " @CategoryId," + "@UnitId," + "@PurchasePrice," + "@SalesPrice," + "@AlterQty," + "@TaxId," + "@IsActive" + " ); SELECT CAST(SCOPE_IDENTITY() as INT); "; result = con.Execute(query, ingredientModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); //CREATE ENTRY INTO INVETORY AS STOCK 0.00 query = " INSERT INTO INVENTORY (STOREID,IngredientId,STOCKQTY,USERIDINSERTED,ISDELETED)" + " Select S.ID as StoreId,FM.Id,0,1,0 from Ingredient FM CROSS JOIN STORE S " + " WHERE FM.ID =" + MaxId; result = con.Execute(query, ingredientModel, sqltrans, 0, System.Data.CommandType.Text); string output = commonRepository.SyncTableStatus("Ingredient"); output = commonRepository.SyncTableStatus("INVENTORY"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertStore(StoreModel storeModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("Store", "StoreName", storeModel.StoreName, storeModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("Store"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO Store (Id,StoreName, IsMainStore,Notes,IsActive,IsLock) " + "VALUES (" + MaxId + ",@StoreName, @IsMainStore,@Notes,@IsActive,@IsLock);" + " SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, storeModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); //CREATE ENTRY INTO INVENTORY WITH ALL FOODMENU WITH STOCKQTY AS 0.00 query = " INSERT INTO INVENTORY(STOREID, FOODMENUID, STOCKQTY, USERIDINSERTED, ISDELETED) " + " Select S.Id,FM.Id,0,1,0 from FoodMenu FM Cross join STORE S Where S.Id = " + MaxId; result = con.Execute(query, storeModel, sqltrans, 0, System.Data.CommandType.Text); //CREATE ENTRY INTO INVENTORY WITH ALL INGREDIENT WITH STOCKQTY AS 0.00 query = " INSERT INTO INVENTORY(STOREID, INGREDIENTid, STOCKQTY, USERIDINSERTED, ISDELETED) " + " Select S.Id,FM.Id,0,1,0 from INGREDIENT FM Cross join STORE S Where S.Id = " + MaxId; result = con.Execute(query, storeModel, sqltrans, 0, System.Data.CommandType.Text); //CREATE ENTRY INTO INVENTORY WITH ALL ASSETITEM WITH STOCKQTY AS 0.00 query = " INSERT INTO INVENTORY(STOREID, ASSETITEMid, STOCKQTY, USERIDINSERTED, ISDELETED) " + " Select S.Id,FM.Id,0,1,0 from ASSETITEM FM Cross join STORE S Where S.Id = " + MaxId; result = con.Execute(query, storeModel, sqltrans, 0, System.Data.CommandType.Text); string output = commonRepository.SyncTableStatus("Store"); output = commonRepository.SyncTableStatus("INVENTORY"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertAssetItem(AssetItemModel assetItemModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("AssetItem", "AssetItemName", assetItemModel.AssetItemName, assetItemModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("AssetItem"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO AssetItem " + "(AssetCategoryId,AssetItemName, ShortName, Code, Brandname, Model, Notes,CostPrice,UnitId,TaxId," + " UserIdInserted, DateInserted,IsDeleted) " + "Values " + "(@AssetCategoryId,@AssetItemName, @ShortName,@Code, @Brandname, @Model,@Notes,@CostPrice,@UnitId,@TaxId," + LoginInfo.Userid + ",GetUtcDate(),0);" + " SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, assetItemModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); //CREATE ENTRY INTO INVETORY AS STOCK 0.00 query = " INSERT INTO INVENTORY (STOREID,AssetItemId,STOCKQTY,USERIDINSERTED,ISDELETED)" + " Select S.ID as StoreId,FM.Id,0,1,0 from AssetItem FM CROSS JOIN STORE S " + " WHERE FM.ID =" + MaxId; result = con.Execute(query, assetItemModel, sqltrans, 0, System.Data.CommandType.Text); string output = commonRepository.SyncTableStatus("AssetItem"); output = commonRepository.SyncTableStatus("Inventory"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertEmployee(EmployeeModel employeeModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("Employee", "Phone", employeeModel.Phone, employeeModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("Employee"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); //HireDate,OriginalHireDate,TerminationDate,RehireDate,DOB, //@HireDate,@OriginalHireDate,@TerminationDate,@RehireDate,@DOB, var query = "INSERT INTO Employee " + "(Id,FirstName,MiddleName,LastName,Designation,Email,Phone,AlterPhone,PresentAdress,PermanentAdress,picture" + //,DegreeName,UniversityName,CGP,PassingYear,CompanyName,WorkingPeriod,Duties,Suoervisor,Signature,State,City,Zip,CitizenShip,TerminationReason,VolunteryTermination,RateType,Rate,PayFrequency,PayFrequencyTxt,HourlyRate2,HourlyRate3,Gender,Country,MaritalStatus,EthnicGroup,SSN,WorkInState,LiveInState,HomeEmail,BusinessEmail,HomePhone,BUsinessPhone,CellPhone,EmergConct,EmergHPhone,EmergWPhone,EmergContctRelation,AltEmContct,AltEmgHPhone,AltEmgWPhone,IsActive) " + " )VALUES " + "(" + MaxId + ", @FirstName,@MiddleName,@LastName,@Designation,@Email,@Phone,@AlterPhone,@PresentAdress,@PermanentAdress,@picture)" + //,@DegreeName,@UniversityName,@CGP,@PassingYear,@CompanyName,@WorkingPeriod,@Duties,@Suoervisor,@Signature,@State,@City,@Zip,@CitizenShip,@TerminationReason,@VolunteryTermination,@RateType,@Rate,@PayFrequency,@PayFrequencyTxt,@HourlyRate2,@HourlyRate3,@Gender,@Country,@MaritalStatus,@EthnicGroup,@SSN,@WorkInState,@LiveInState,@HomeEmail,@BusinessEmail,@HomePhone,@BUsinessPhone,@CellPhone,@EmergConct,@EmergHPhone,@EmergWPhone,@EmergContctRelation,@AltEmContct,@AltEmgHPhone,@AltEmgWPhone,@IsActive);" + " SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, employeeModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("Employee"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertUser(UserModel UserModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("[User]", "Username", UserModel.Username, UserModel.Id.ToString()); if (result > 0) { return(-1); } UserModel.RoleTypeId = (UserModel.RoleTypeId == 0) ? null : UserModel.RoleTypeId; int MaxId = commonRepository.GetMaxId("[User]"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); //LastLogin,LastLogout, var query = "INSERT INTO [User] (Id,EmployeeId,OutletId,Username,Password,ThumbToken,RoleTypeId,IPAdress,Counter,IsActive,WebRoleId) " + "Values" + " (" + MaxId + ",@EmployeeId,@OutletId,@Username,@Password,@ThumbToken,@RoleTypeId,@IPAdress,@Counter,@IsActive,@WebRoleId); " + "SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, UserModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("[User]"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertBank(BankModel bankModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("Bank", "BankName", bankModel.BankName, bankModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("Bank"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO Bank (Id,BankName," + "AccountName,AccountNumber,Branch,SignaturePicture) " + "VALUES (" + MaxId + ",@BankName," + "@AccountName,@AccountNumber,@Branch,@SignaturePicture " + "); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, bankModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("Bank"); } else { sqltrans.Rollback(); } } return(result); }
public int InsertRawMaterial(RawMaterialModel rawMaterialModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("RawMaterial", "RawMaterialName", rawMaterialModel.RawMaterialName, rawMaterialModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("RawMaterial"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO RawMaterial (Id,RawMaterialName," + "Notes, " + "IsActive,UserIdInserted,DateInserted,IsDeleted)" + "VALUES (" + MaxId + ",@RawMaterialName," + "@Notes," + "@IsActive," + LoginInfo.Userid + ",GetUtcDate(),0); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, rawMaterialModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("RawMaterial"); } else { sqltrans.Rollback(); } return(result); } }
public int InsertIngredientCategory(IngredientCategoryModel ingredientCategoryModel) { int result = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); result = commonRepository.GetValidateUnique("IngredientCategory", "IngredientCategoryName", ingredientCategoryModel.IngredientCategoryName, ingredientCategoryModel.Id.ToString()); if (result > 0) { return(-1); } int MaxId = commonRepository.GetMaxId("IngredientCategory"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO IngredientCategory (Id,IngredientCategoryName," + "RawMaterialId,Notes, " + "IsActive)" + "VALUES (" + MaxId + ",@IngredientCategoryName," + "@RawMaterialId,@Notes," + "@IsActive); SELECT CAST(SCOPE_IDENTITY() as INT);"; result = con.Execute(query, ingredientCategoryModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { sqltrans.Commit(); string output = commonRepository.SyncTableStatus("IngredientCategory"); } else { sqltrans.Rollback(); } return(result); } }
public int InsertUpdateFoodMenuIngredient(FoodMenuIngredientModel foodMenuIngredientModel) { int result = 0, detailResult = 0; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { CommonRepository commonRepository = new CommonRepository(_ConnectionString); int MaxId = commonRepository.GetMaxId("FoodMenuIngredient"); con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); int deleteResult = 0; if (foodMenuIngredientModel.DeletedId != null) { foreach (var item in foodMenuIngredientModel.DeletedId) { var deleteQuery = $"update FoodMenuIngredient set IsDeleted = 1, UserIdDeleted = " + LoginInfo.Userid + ", DateDeleted = GetutcDate() where id = " + item + ";"; deleteResult = con.Execute(deleteQuery, null, sqltrans, 0, System.Data.CommandType.Text); } } foreach (var item in foodMenuIngredientModel.FoodMenuIngredientDetails) { var query = string.Empty; if (item.Id > 0) { query = "update FoodMenuIngredient set " + "FoodMenuId =" + item.FoodMenuId + "," + "IngredientId =" + item.IngredientId + "," + "Consumption = " + item.Consumption + "," + "UserIdUpdated =" + LoginInfo.Userid + "," + "DateUpdated=getutcdate(),IsDeleted = 0 Where Id=" + item.Id; } else { query = "INSERT INTO FoodMenuIngredient" + " (Id " + " ,FoodMenuId " + " ,IngredientId " + " ,Consumption" + " ,UserIdInserted" + " ,DateInserted,IsDeleted) " + "VALUES " + "(" + MaxId.ToString() + "," + +item.FoodMenuId + "," + item.IngredientId + "," + item.Consumption + "," + LoginInfo.Userid + ",GetUtcDate(),0);"; MaxId = MaxId + 1; } detailResult = con.Execute(query, null, sqltrans, 0, System.Data.CommandType.Text); } if (detailResult > 0) { result = 1; sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(result); }