public string TrasactionsAuthenticationInsert(tbl_TrasactionsAuthentication TrasactionsAuthentication) { string result = string.Empty; try { Context.TrasactionsAuthentication.Insert(TrasactionsAuthentication); Context.TrasactionsAuthentication.Save(); result = TrasactionsAuthentication.Id + "Insert Successfully..."; } catch (Exception ex) { result = "Error..."; } return(result); }
public string SaveAuthentication(UserAuthenticationModel UserAuthenticationModel, string UserLocations, string ManagerLocations) { string result = string.Empty; try { bool LocationAuthenticationCheck = false; bool MasterDataAuthenticationCheck = false; bool TrasactionsAuthenticationCheck = false; bool EnquiryAuthenticationCheck = false; bool SetupAuthenticationCheck = false; bool AspNetUserRoleCheck = false; List <tbl_LocationAuthentication> LocationAuthentication; LocationAuthentication = this.LocationAuthenticationGetByEmail(UserAuthenticationModel.Email); tbl_LocationAuthentication Location = new tbl_LocationAuthentication(); if (LocationAuthentication == null || LocationAuthentication.Count == 0) { Location.UserId = UserAuthenticationModel.UserId; Location.User_Locations = UserLocations; Location.Manager_Locations = ManagerLocations; Location.Email = UserAuthenticationModel.Email; } else { LocationAuthenticationCheck = true; LocationAuthentication.FirstOrDefault().UserId = UserAuthenticationModel.UserId; LocationAuthentication.FirstOrDefault().User_Locations = UserLocations; LocationAuthentication.FirstOrDefault().Manager_Locations = ManagerLocations; LocationAuthentication.FirstOrDefault().Email = UserAuthenticationModel.Email; } // LocationAuthentication if (LocationAuthenticationCheck) { this.LocationAuthenticationUpdate(LocationAuthentication.FirstOrDefault()); } else { this.LocationAuthenticationInsert(Location); } List <tbl_LocationAuthentication> CLocationAuth = this.LocationAuthenticationGetByEmail(UserAuthenticationModel.Email); UserAuthenticationModel.Loc_Auth_Id = CLocationAuth.FirstOrDefault().Id; List <AspNetUser> Users = this.AspNetUserGetByUserId(UserAuthenticationModel.UserId); if (Users.Count > 0) { Users.FirstOrDefault().Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; this.AspNetUserUpdate(Users.FirstOrDefault()); } List <AspNetUserRole> AspNetUserRole = this.AspNetUserRoleLoc_Anth_Id(UserAuthenticationModel.Loc_Auth_Id); AspNetUserRole IUAspNetUserRole = new Entity.Entities.AspNetUserRole(); if (AspNetUserRole == null || AspNetUserRole.Count == 0) { IUAspNetUserRole.UserId = UserAuthenticationModel.UserId; IUAspNetUserRole.RoleId = UserAuthenticationModel.RoleId; IUAspNetUserRole.Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; } else { AspNetUserRoleCheck = true; AspNetUserRole.FirstOrDefault().UserId = UserAuthenticationModel.UserId; AspNetUserRole.FirstOrDefault().RoleId = UserAuthenticationModel.RoleId; AspNetUserRole.FirstOrDefault().Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; } if (AspNetUserRoleCheck) { this.AspNetUserRoleUpdate(AspNetUserRole.FirstOrDefault()); } else { this.AspNetUserRoleInsert(IUAspNetUserRole); } //MasterDataAuthentication List <tbl_MasterDataAuthentication> MasterDataAuthentication; MasterDataAuthentication = this.MasterDataAuthenticationLoc_Auth_Id(UserAuthenticationModel.Loc_Auth_Id); tbl_MasterDataAuthentication MasterData = new tbl_MasterDataAuthentication(); if (MasterDataAuthentication == null || MasterDataAuthentication.Count == 0) { MasterData.Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; MasterData.Location = UserAuthenticationModel.Location; MasterData.Terminal = UserAuthenticationModel.Terminal; MasterData.Storage = UserAuthenticationModel.Storage; MasterData.Vendor = UserAuthenticationModel.Vendor; MasterData.Customer = UserAuthenticationModel.Customer; MasterData.Category = UserAuthenticationModel.Category; MasterData.SubCategory = UserAuthenticationModel.SubCategory; MasterData.UOM = UserAuthenticationModel.UOM; MasterData.Material = UserAuthenticationModel.Material; MasterData.Price = UserAuthenticationModel.Price; MasterData.LocationPrice = UserAuthenticationModel.LocationPrice; MasterData.Users = UserAuthenticationModel.Users; MasterData.City = UserAuthenticationModel.City; MasterData.Region = UserAuthenticationModel.Region; MasterData.Country = UserAuthenticationModel.Country; } else { MasterDataAuthenticationCheck = true; MasterDataAuthentication.FirstOrDefault().Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; MasterDataAuthentication.FirstOrDefault().Location = UserAuthenticationModel.Location; MasterDataAuthentication.FirstOrDefault().Terminal = UserAuthenticationModel.Terminal; MasterDataAuthentication.FirstOrDefault().Storage = UserAuthenticationModel.Storage; MasterDataAuthentication.FirstOrDefault().Vendor = UserAuthenticationModel.Vendor; MasterDataAuthentication.FirstOrDefault().Customer = UserAuthenticationModel.Customer; MasterDataAuthentication.FirstOrDefault().Category = UserAuthenticationModel.Category; MasterDataAuthentication.FirstOrDefault().SubCategory = UserAuthenticationModel.SubCategory; MasterDataAuthentication.FirstOrDefault().UOM = UserAuthenticationModel.UOM; MasterDataAuthentication.FirstOrDefault().Material = UserAuthenticationModel.Material; MasterDataAuthentication.FirstOrDefault().Price = UserAuthenticationModel.Price; MasterDataAuthentication.FirstOrDefault().LocationPrice = UserAuthenticationModel.LocationPrice; MasterDataAuthentication.FirstOrDefault().Users = UserAuthenticationModel.Users; MasterDataAuthentication.FirstOrDefault().City = UserAuthenticationModel.City; MasterDataAuthentication.FirstOrDefault().Region = UserAuthenticationModel.Region; MasterDataAuthentication.FirstOrDefault().Country = UserAuthenticationModel.Country; } // TrasactionsAuthentication List <tbl_TrasactionsAuthentication> TrasactionsAuthentication; TrasactionsAuthentication = this.TrasactionsAuthenticationLoc_Auth_Id(UserAuthenticationModel.Loc_Auth_Id); tbl_TrasactionsAuthentication Trasaction = new tbl_TrasactionsAuthentication(); if (TrasactionsAuthentication == null || TrasactionsAuthentication.Count == 0) { Trasaction.Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; Trasaction.SalesOrder = UserAuthenticationModel.TSalesOrder; Trasaction.POReceive = UserAuthenticationModel.TPOReceive; Trasaction.ReturnToSupplier = UserAuthenticationModel.TReturnToSupplier; Trasaction.TranfterToDisplay = UserAuthenticationModel.TTranfterToDisplay; Trasaction.TransfterIN = UserAuthenticationModel.TTransfterIN; Trasaction.TransfterOUT = UserAuthenticationModel.TTransfterOUT; Trasaction.PhysicalInventory = UserAuthenticationModel.TPhysicalInventory; Trasaction.PuchaseOrder = UserAuthenticationModel.TPuchaseOrder; Trasaction.CashCollection = UserAuthenticationModel.TCashCollection; Trasaction.ProductionOrder = UserAuthenticationModel.TProductionOrder; } else { TrasactionsAuthenticationCheck = true; TrasactionsAuthentication.FirstOrDefault().Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; TrasactionsAuthentication.FirstOrDefault().SalesOrder = UserAuthenticationModel.TSalesOrder; TrasactionsAuthentication.FirstOrDefault().POReceive = UserAuthenticationModel.TPOReceive; TrasactionsAuthentication.FirstOrDefault().ReturnToSupplier = UserAuthenticationModel.TReturnToSupplier; TrasactionsAuthentication.FirstOrDefault().TranfterToDisplay = UserAuthenticationModel.TTranfterToDisplay; TrasactionsAuthentication.FirstOrDefault().TransfterIN = UserAuthenticationModel.TTransfterIN; TrasactionsAuthentication.FirstOrDefault().TransfterOUT = UserAuthenticationModel.TTransfterOUT; TrasactionsAuthentication.FirstOrDefault().PhysicalInventory = UserAuthenticationModel.TPhysicalInventory; TrasactionsAuthentication.FirstOrDefault().PuchaseOrder = UserAuthenticationModel.TPuchaseOrder; TrasactionsAuthentication.FirstOrDefault().CashCollection = UserAuthenticationModel.TCashCollection; TrasactionsAuthentication.FirstOrDefault().ProductionOrder = UserAuthenticationModel.TProductionOrder; } // EnquiryAuthentication List <tbl_EnquiryAuthentication> EnquiryAuthentication; EnquiryAuthentication = this.EnquiryAuthenticationLoc_Auth_Id(UserAuthenticationModel.Loc_Auth_Id); tbl_EnquiryAuthentication Enquiry = new tbl_EnquiryAuthentication(); if (EnquiryAuthentication == null || EnquiryAuthentication.Count == 0) { Enquiry.Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; Enquiry.SalesOrder = UserAuthenticationModel.SalesOrder; Enquiry.POReceive = UserAuthenticationModel.POReceive; Enquiry.ReturnToSupplier = UserAuthenticationModel.ReturnToSupplier; Enquiry.TranfterToDisplay = UserAuthenticationModel.TranfterToDisplay; Enquiry.PhysicalInventory = UserAuthenticationModel.PhysicalInventory; Enquiry.TransfterIN = UserAuthenticationModel.TransfterIN; Enquiry.TransfterOUT = UserAuthenticationModel.TransfterOUT; Enquiry.EOD = UserAuthenticationModel.EOD; } else { EnquiryAuthenticationCheck = true; EnquiryAuthentication.FirstOrDefault().Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; EnquiryAuthentication.FirstOrDefault().SalesOrder = UserAuthenticationModel.SalesOrder; EnquiryAuthentication.FirstOrDefault().POReceive = UserAuthenticationModel.POReceive; EnquiryAuthentication.FirstOrDefault().ReturnToSupplier = UserAuthenticationModel.ReturnToSupplier; EnquiryAuthentication.FirstOrDefault().TranfterToDisplay = UserAuthenticationModel.TranfterToDisplay; EnquiryAuthentication.FirstOrDefault().TransfterIN = UserAuthenticationModel.TransfterIN; EnquiryAuthentication.FirstOrDefault().PhysicalInventory = UserAuthenticationModel.PhysicalInventory; EnquiryAuthentication.FirstOrDefault().TransfterOUT = UserAuthenticationModel.TransfterOUT; EnquiryAuthentication.FirstOrDefault().EOD = UserAuthenticationModel.EOD; } // SetupAuthentication List <tbl_SetupAuthentication> SetupAuthentication; SetupAuthentication = this.SetupAuthenticationLoc_Auth_Id(UserAuthenticationModel.Loc_Auth_Id); tbl_SetupAuthentication Setup = new tbl_SetupAuthentication(); if (SetupAuthentication == null || SetupAuthentication.Count == 0) { Setup.Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; Setup.ChangePassword = UserAuthenticationModel.ChangePassword; Setup.AddUsers = UserAuthenticationModel.AddUsers; Setup.UsersAuthentication = UserAuthenticationModel.UsersAuthentication; Setup.Reports = UserAuthenticationModel.Reports; Setup.ProductionOrderStatusReport = UserAuthenticationModel.ProductionOrderStatusReport; Setup.LostOpporTunitySalesReport = UserAuthenticationModel.LostOpporTunitySalesReport; } else { SetupAuthenticationCheck = true; SetupAuthentication.FirstOrDefault().Loc_Auth_Id = UserAuthenticationModel.Loc_Auth_Id; SetupAuthentication.FirstOrDefault().ChangePassword = UserAuthenticationModel.ChangePassword; SetupAuthentication.FirstOrDefault().AddUsers = UserAuthenticationModel.AddUsers; SetupAuthentication.FirstOrDefault().UsersAuthentication = UserAuthenticationModel.UsersAuthentication; SetupAuthentication.FirstOrDefault().Reports = UserAuthenticationModel.Reports; SetupAuthentication.FirstOrDefault().ProductionOrderStatusReport = UserAuthenticationModel.ProductionOrderStatusReport; SetupAuthentication.FirstOrDefault().LostOpporTunitySalesReport = UserAuthenticationModel.LostOpporTunitySalesReport; } if (MasterDataAuthenticationCheck) { this.MasterDataAuthenticationUpdate(MasterDataAuthentication.FirstOrDefault()); } else { this.MasterDataAuthenticationInsert(MasterData); } if (TrasactionsAuthenticationCheck) { this.TrasactionsAuthenticationUpdate(TrasactionsAuthentication.FirstOrDefault()); } else { this.TrasactionsAuthenticationInsert(Trasaction); } if (EnquiryAuthenticationCheck) { this.EnquiryAuthenticationUpdate(EnquiryAuthentication.FirstOrDefault()); } else { this.EnquiryAuthenticationInsert(Enquiry); } if (SetupAuthenticationCheck) { this.SetupAuthenticationUpdate(SetupAuthentication.FirstOrDefault()); } else { this.SetupAuthenticationInsert(Setup); } result = "User Security added successfully..."; } catch (Exception ex) { result = "Error..."; throw; } return(result); }