public override T Convert <T, U>(U entity) { Location location = entity as Location; if (location == null) { return(default(T)); } BO.Location locationBO = new BO.Location(); locationBO.ID = location.id; locationBO.Name = location.Name; locationBO.IsDefault = location.IsDefault; locationBO.LocationType = (BO.GBEnums.LocationType)location.LocationType; if (location.IsDeleted.HasValue) { locationBO.IsDeleted = location.IsDeleted.Value; } if (location.UpdateByUserID.HasValue) { locationBO.UpdateByUserID = location.UpdateByUserID.Value; } if (location.Company != null) { BO.Company boCompany = new BO.Company(); boCompany.ID = location.Company.id; boCompany.Name = location.Company.Name; boCompany.TaxID = location.Company.TaxID; boCompany.Status = (BO.GBEnums.AccountStatus)location.Company.Status; boCompany.CompanyType = (BO.GBEnums.CompanyType)location.Company.CompanyType; if (location.Company.SubscriptionPlanType != null) { boCompany.SubsCriptionType = (BO.GBEnums.SubsCriptionType)location.Company.SubscriptionPlanType; } else { boCompany.SubsCriptionType = null; } locationBO.Company = boCompany; } if (location.AddressInfo != null) { BO.AddressInfo boAddress = new BO.AddressInfo(); boAddress.Name = location.AddressInfo.Name; boAddress.Address1 = location.AddressInfo.Address1; boAddress.Address2 = location.AddressInfo.Address2; boAddress.City = location.AddressInfo.City; boAddress.State = location.AddressInfo.State; boAddress.ZipCode = location.AddressInfo.ZipCode; boAddress.Country = location.AddressInfo.Country; //[STATECODE-CHANGE] //boAddress.StateCode = location.AddressInfo.StateCode; //[STATECODE-CHANGE] boAddress.CreateByUserID = location.AddressInfo.CreateByUserID; boAddress.ID = location.AddressInfo.id; if (location.AddressInfo.IsDeleted.HasValue) { boAddress.IsDeleted = location.AddressInfo.IsDeleted.Value; } if (location.AddressInfo.UpdateByUserID.HasValue) { boAddress.UpdateByUserID = location.AddressInfo.UpdateByUserID.Value; } locationBO.AddressInfo = boAddress; } if (location.ContactInfo != null) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.Name = location.ContactInfo.Name; boContactInfo.CellPhone = location.ContactInfo.CellPhone; boContactInfo.EmailAddress = location.ContactInfo.EmailAddress; boContactInfo.HomePhone = location.ContactInfo.HomePhone; boContactInfo.WorkPhone = location.ContactInfo.WorkPhone; boContactInfo.FaxNo = location.ContactInfo.FaxNo; boContactInfo.CreateByUserID = location.ContactInfo.CreateByUserID; boContactInfo.ID = location.ContactInfo.id; if (location.ContactInfo.IsDeleted.HasValue) { boContactInfo.IsDeleted = location.ContactInfo.IsDeleted.Value; } if (location.ContactInfo.UpdateByUserID.HasValue) { boContactInfo.UpdateByUserID = location.ContactInfo.UpdateByUserID.Value; } locationBO.ContactInfo = boContactInfo; } BO.Schedule boSchedule = new BO.Schedule(); using (ScheduleRepository cmp = new ScheduleRepository(_context)) { boSchedule = cmp.Convert <BO.Schedule, Schedule>(location.Schedule); // cmp.Save(boSchedule); locationBO.Schedule = boSchedule; } return((T)(object)locationBO); }
public override T ObjectConvert <T, U>(U entity) { InsuranceMaster insuranceMaster = entity as InsuranceMaster; if (insuranceMaster == null) { return(default(T)); } BO.InsuranceMaster boInsuranceMaster = new BO.InsuranceMaster(); boInsuranceMaster.ID = insuranceMaster.Id; boInsuranceMaster.CompanyCode = insuranceMaster.CompanyCode; boInsuranceMaster.CompanyName = insuranceMaster.CompanyName; boInsuranceMaster.AddressInfoId = insuranceMaster.AddressInfoId; boInsuranceMaster.ContactInfoId = insuranceMaster.ContactInfoId; boInsuranceMaster.ZeusID = insuranceMaster.ZeusID; boInsuranceMaster.PriorityBilling = insuranceMaster.PriorityBilling; boInsuranceMaster.Only1500Form = insuranceMaster.Only1500Form; boInsuranceMaster.PaperAuthorization = insuranceMaster.PaperAuthorization; boInsuranceMaster.CreatedByCompanyId = insuranceMaster.CreatedByCompanyId; //if (insuranceMaster.IsDeleted.HasValue) // boInsuranceMaster.IsDeleted = insuranceMaster.IsDeleted.Value; if (insuranceMaster.AddressInfo != null) { BO.AddressInfo boAddress = new BO.AddressInfo(); boAddress.Name = insuranceMaster.AddressInfo.Name; boAddress.Address1 = insuranceMaster.AddressInfo.Address1; boAddress.Address2 = insuranceMaster.AddressInfo.Address2; boAddress.City = insuranceMaster.AddressInfo.City; boAddress.State = insuranceMaster.AddressInfo.State; boAddress.ZipCode = insuranceMaster.AddressInfo.ZipCode; boAddress.Country = insuranceMaster.AddressInfo.Country; boAddress.CreateByUserID = insuranceMaster.AddressInfo.CreateByUserID; boAddress.ID = insuranceMaster.AddressInfo.id; boAddress.IsDeleted = insuranceMaster.AddressInfo.IsDeleted; boInsuranceMaster.AddressInfo = boAddress; } if (insuranceMaster.ContactInfo != null) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.Name = insuranceMaster.ContactInfo.Name; boContactInfo.CellPhone = insuranceMaster.ContactInfo.CellPhone; boContactInfo.EmailAddress = insuranceMaster.ContactInfo.EmailAddress; boContactInfo.HomePhone = insuranceMaster.ContactInfo.HomePhone; boContactInfo.WorkPhone = insuranceMaster.ContactInfo.WorkPhone; boContactInfo.FaxNo = insuranceMaster.ContactInfo.FaxNo; boContactInfo.OfficeExtension = insuranceMaster.ContactInfo.OfficeExtension; boContactInfo.AlternateEmail = insuranceMaster.ContactInfo.AlternateEmail; boContactInfo.PreferredCommunication = insuranceMaster.ContactInfo.PreferredCommunication; boContactInfo.CreateByUserID = insuranceMaster.ContactInfo.CreateByUserID; boContactInfo.ID = insuranceMaster.ContactInfo.id; boContactInfo.IsDeleted = insuranceMaster.ContactInfo.IsDeleted; boInsuranceMaster.ContactInfo = boContactInfo; } boInsuranceMaster.IsDeleted = insuranceMaster.IsDeleted; boInsuranceMaster.CreateByUserID = insuranceMaster.CreateByUserID; boInsuranceMaster.UpdateByUserID = insuranceMaster.UpdateByUserID; return((T)(object)boInsuranceMaster); }
public override T Convert <T, U>(U entity) { AdjusterMaster adjusterMasterDB = entity as AdjusterMaster; if (adjusterMasterDB == null) { return(default(T)); } BO.AdjusterMaster adjusterMasterBO = new BO.AdjusterMaster(); adjusterMasterBO.ID = adjusterMasterDB.Id; adjusterMasterBO.CompanyId = adjusterMasterDB.CompanyId; adjusterMasterBO.FirstName = adjusterMasterDB.FirstName; adjusterMasterBO.MiddleName = adjusterMasterDB.MiddleName; adjusterMasterBO.LastName = adjusterMasterDB.LastName; adjusterMasterBO.InsuranceMasterId = adjusterMasterDB.InsuranceMasterId; adjusterMasterBO.AddressInfoId = adjusterMasterDB.AddressInfoId; adjusterMasterBO.ContactInfoId = adjusterMasterDB.ContactInfoId; if (adjusterMasterDB.AddressInfo != null) { BO.AddressInfo boAddress = new BO.AddressInfo(); boAddress.Name = adjusterMasterDB.AddressInfo.Name; boAddress.Address1 = adjusterMasterDB.AddressInfo.Address1; boAddress.Address2 = adjusterMasterDB.AddressInfo.Address2; boAddress.City = adjusterMasterDB.AddressInfo.City; boAddress.State = adjusterMasterDB.AddressInfo.State; boAddress.ZipCode = adjusterMasterDB.AddressInfo.ZipCode; boAddress.Country = adjusterMasterDB.AddressInfo.Country; //[STATECODE-CHANGE] //boAddress.StateCode = adjusterMasterDB.AddressInfo.StateCode; //[STATECODE-CHANGE] boAddress.CreateByUserID = adjusterMasterDB.AddressInfo.CreateByUserID; boAddress.ID = adjusterMasterDB.AddressInfo.id; adjusterMasterBO.AddressInfo = boAddress; } if (adjusterMasterDB.ContactInfo != null) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.Name = adjusterMasterDB.ContactInfo.Name; boContactInfo.CellPhone = adjusterMasterDB.ContactInfo.CellPhone; boContactInfo.EmailAddress = adjusterMasterDB.ContactInfo.EmailAddress; boContactInfo.HomePhone = adjusterMasterDB.ContactInfo.HomePhone; boContactInfo.WorkPhone = adjusterMasterDB.ContactInfo.WorkPhone; boContactInfo.FaxNo = adjusterMasterDB.ContactInfo.FaxNo; boContactInfo.CreateByUserID = adjusterMasterDB.ContactInfo.CreateByUserID; boContactInfo.ID = adjusterMasterDB.ContactInfo.id; boContactInfo.OfficeExtension = adjusterMasterDB.ContactInfo.OfficeExtension; boContactInfo.AlternateEmail = adjusterMasterDB.ContactInfo.AlternateEmail; boContactInfo.PreferredCommunication = adjusterMasterDB.ContactInfo.PreferredCommunication; adjusterMasterBO.ContactInfo = boContactInfo; } //Common adjusterMasterBO.IsDeleted = adjusterMasterDB.IsDeleted; adjusterMasterBO.CreateByUserID = adjusterMasterDB.CreateByUserID; adjusterMasterBO.UpdateByUserID = adjusterMasterDB.UpdateByUserID; return((T)(object)adjusterMasterBO); }
public override object Save <T>(T entity) { BO.SaveLocation saveLocationBO = (BO.SaveLocation)(object) entity; if (saveLocationBO.location == null) { return(new BO.ErrorObject { ErrorMessage = "Location object can't be null", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (saveLocationBO.location.ID == 0) { if (saveLocationBO.addressInfo == null) { return(new BO.ErrorObject { ErrorMessage = "Addressinfo object can't be null", errorObject = "", ErrorLevel = ErrorLevel.Error }); } } if (saveLocationBO.location.ID == 0) { if (saveLocationBO.contactInfo == null) { return(new BO.ErrorObject { ErrorMessage = "Contactinfo object can't be null", errorObject = "", ErrorLevel = ErrorLevel.Error }); } } if (saveLocationBO.location.ID == 0) { if (saveLocationBO.company == null) { return(new BO.ErrorObject { ErrorMessage = "Company object can't be null", errorObject = "", ErrorLevel = ErrorLevel.Error }); } } BO.Location locationBO = saveLocationBO.location; BO.Company companyBO = saveLocationBO.company; BO.AddressInfo addressBO = saveLocationBO.addressInfo; BO.ContactInfo contactinfoBO = saveLocationBO.contactInfo; Location locationDB = new Location(); Company companyDB = new Company(); User userDB = new User(); AddressInfo addressDB = new AddressInfo(); ContactInfo contactinfoDB = new ContactInfo(); #region Location locationDB.id = locationBO.ID; locationDB.Name = locationBO.Name; locationDB.LocationType = System.Convert.ToByte(locationBO.LocationType); locationDB.IsDefault = locationBO.IsDefault; locationDB.IsDeleted = locationBO.IsDeleted.HasValue ? locationBO.IsDeleted : false; #endregion #region Company if (companyBO.ID > 0) { Company company = _context.Companies.Where(p => p.id == companyBO.ID).FirstOrDefault <Company>(); if (company != null) { locationDB.Company = company; _context.Entry(company).State = System.Data.Entity.EntityState.Modified; } else { return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Company details.", ErrorLevel = ErrorLevel.Error } }; } #endregion #region Address if (addressBO != null) { addressDB.id = addressBO.ID; addressDB.Name = addressBO.Name; addressDB.Address1 = addressBO.Address1; addressDB.Address2 = addressBO.Address2; addressDB.City = addressBO.City; addressDB.State = addressBO.State; addressDB.ZipCode = addressBO.ZipCode; addressDB.Country = addressBO.Country; //[STATECODE-CHANGE] //addressDB.StateCode = addressBO.StateCode; //[STATECODE-CHANGE] } #endregion #region Contact Info if (contactinfoBO != null) { contactinfoDB.id = contactinfoBO.ID; contactinfoDB.Name = contactinfoBO.Name; contactinfoDB.CellPhone = contactinfoBO.CellPhone; contactinfoDB.EmailAddress = contactinfoBO.EmailAddress; contactinfoDB.HomePhone = contactinfoBO.HomePhone; contactinfoDB.WorkPhone = contactinfoBO.WorkPhone; contactinfoDB.FaxNo = contactinfoBO.FaxNo; if (contactinfoBO.IsDeleted.HasValue) { contactinfoDB.IsDeleted = contactinfoBO.IsDeleted; } } #endregion //Added code to get data in AddressInfo and ContactInfo locationDB.AddressInfo = addressDB; locationDB.ContactInfo = contactinfoDB; if (saveLocationBO.schedule != null) { #region Schedule if (saveLocationBO.schedule != null) { if (saveLocationBO.schedule.ID > 0) { Schedule schedule = _context.Schedules.Where(p => p.id == saveLocationBO.schedule.ID).FirstOrDefault <Schedule>(); if (schedule != null) { locationDB.Schedule = schedule; } else { return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Schedule.", ErrorLevel = ErrorLevel.Error } }; } } #endregion } else { //Default schedule Schedule defaultschedule = _context.Schedules.Where(p => p.IsDefault == true).FirstOrDefault <Schedule>(); if (defaultschedule != null) { locationDB.Schedule = defaultschedule; } else { return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please set default schedule in database.", ErrorLevel = ErrorLevel.Error } }; } if (locationDB.id > 0) { //For Update Record //Find Location By ID Location location = _context.Locations.Include("Company").Include("ContactInfo").Include("AddressInfo").Where(p => p.id == locationDB.id).FirstOrDefault <Location>(); if (location != null) { #region Location locationDB.id = locationBO.ID; location.Name = locationBO.Name == null ? location.Name : locationBO.Name; location.LocationType = locationBO.LocationType == null ? location.LocationType : System.Convert.ToByte(locationBO.LocationType); location.IsDefault = locationBO.IsDefault; location.IsDeleted = locationBO.IsDeleted == null ? locationBO.IsDeleted : locationDB.IsDeleted; location.UpdateDate = locationBO.UpdateDate; location.UpdateByUserID = locationBO.UpdateByUserID; #endregion #region AddressInfo location.AddressInfo.CreateByUserID = location.CreateByUserID; location.AddressInfo.CreateDate = location.CreateDate; if (locationBO.UpdateByUserID.HasValue) { location.AddressInfo.UpdateByUserID = locationBO.UpdateByUserID.Value; } location.AddressInfo.UpdateDate = DateTime.UtcNow; location.AddressInfo.Name = addressBO.Name; location.AddressInfo.Address1 = addressBO.Address1; location.AddressInfo.Address2 = addressBO.Address2; location.AddressInfo.City = addressBO.City; location.AddressInfo.State = addressBO.State; location.AddressInfo.ZipCode = addressBO.ZipCode; location.AddressInfo.Country = addressBO.Country; //[STATECODE-CHANGE] //location.AddressInfo.StateCode = addressBO.StateCode; //[STATECODE-CHANGE] location.AddressInfo.UpdateDate = addressBO.UpdateDate; location.AddressInfo.UpdateByUserID = addressBO.UpdateByUserID; #endregion #region Contact Info location.ContactInfo.CreateByUserID = location.CreateByUserID; location.ContactInfo.CreateDate = location.CreateDate; if (locationBO.UpdateByUserID.HasValue) { location.ContactInfo.UpdateByUserID = locationBO.UpdateByUserID.Value; } location.ContactInfo.UpdateDate = DateTime.UtcNow; location.ContactInfo.Name = contactinfoBO.Name; location.ContactInfo.CellPhone = contactinfoBO.CellPhone; location.ContactInfo.EmailAddress = contactinfoBO.EmailAddress; location.ContactInfo.HomePhone = contactinfoBO.HomePhone; location.ContactInfo.WorkPhone = contactinfoBO.WorkPhone; location.ContactInfo.FaxNo = contactinfoBO.FaxNo; location.ContactInfo.UpdateDate = contactinfoBO.UpdateDate; location.ContactInfo.UpdateByUserID = contactinfoBO.UpdateByUserID; #endregion #region Schedule if (saveLocationBO.schedule != null) { if (saveLocationBO.schedule.ID > 0) { Schedule schedule = _context.Schedules.Where(p => p.id == saveLocationBO.schedule.ID).FirstOrDefault <Schedule>(); if (schedule != null) { location.Schedule = schedule; } else { return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Schedule.", ErrorLevel = ErrorLevel.Error } }; } } #endregion _context.Entry(location).State = System.Data.Entity.EntityState.Modified; } } else { locationDB.CreateDate = companyBO.CreateDate; locationDB.CreateByUserID = companyBO.CreateByUserID; addressDB.CreateDate = companyBO.CreateDate; addressDB.CreateByUserID = companyBO.CreateByUserID; contactinfoDB.CreateDate = companyBO.CreateDate; contactinfoDB.CreateByUserID = companyBO.CreateByUserID; locationDB.AddressInfo = addressDB; locationDB.ContactInfo = contactinfoDB; _dbSet.Add(locationDB); } _context.SaveChanges(); var res = Convert <BO.Location, Location>(locationDB); return((object)res); }
public override Object UpdateCompany <T>(T data) { BO.Signup signUPBO = (BO.Signup)(object) data; BO.User userBO = signUPBO.user; BO.Company companyBO = signUPBO.company; BO.AddressInfo addressBO = signUPBO.addressInfo; BO.ContactInfo contactinfoBO = signUPBO.contactInfo; BO.Role roleBO = signUPBO.role; Guid invitationDB_UniqueID = Guid.NewGuid(); Company companyDB = new Company(); User userDB = new User(); AddressInfo addressDB = new AddressInfo(); ContactInfo contactinfoDB = new ContactInfo(); UserCompany userCompanyDB = new UserCompany(); UserCompanyRole userCompanyRoleDB = new UserCompanyRole(); Invitation invitationDB = new Invitation(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { if (signUPBO == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (signUPBO.company == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (signUPBO.user == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (signUPBO.contactInfo == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } #region Company companyDB = _context.Companies.Where(p => p.id == companyBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (companyDB == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Company Record Not Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } companyDB.TaxID = companyBO.TaxID; if (companyBO.SubsCriptionType != null) { companyDB.SubscriptionPlanType = (int)companyBO.SubsCriptionType; } else { companyDB.SubscriptionPlanType = null; } companyDB.CompanyStatusTypeID = 2; // CompanyStatusTypeID = 2 --- RegistrationComplete _context.SaveChanges(); #endregion #region contactInfo contactinfoDB = _context.ContactInfoes.Where(p => p.id == contactinfoBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (contactinfoDB == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Contact Record Not Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } contactinfoDB.CellPhone = contactinfoBO.CellPhone; _context.SaveChanges(); #endregion #region User userDB = _context.Users.Where(p => p.id == userBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (userDB == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "User Record Not Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } userDB.FirstName = userBO.FirstName; userDB.LastName = userBO.LastName; userDB.C2FactAuthEmailEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactEmail")); userDB.C2FactAuthSMSEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactSMS")); #region password BO.ResetPassword resetPassword = new BO.ResetPassword(); resetPassword.OldPassword = userDB.Password; //if (userDB != null) //{ // resetPassword.NewPassword = PasswordHash.HashPassword(userBO.Password); // userDB.Password = resetPassword.NewPassword; // } if (userDB != null) { if (companyDB.CompanyStatusTypeID == 2) //CompanyStatusTypeID == 2 --- Registration Complete { resetPassword.NewPassword = PasswordHash.HashPassword(userBO.Password); userDB.Password = resetPassword.NewPassword; companyDB.CompanyStatusTypeID = 3; //CompanyStatusTypeID = 3 --- Active } } #endregion _context.SaveChanges(); userDB = _context.Users.Where(p => p.id == userBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); #endregion dbContextTransaction.Commit(); } BO.Company acc_ = Convert <BO.Company, Company>(companyDB); try { if (userDB != null) { var updateCompany = _context.MailTemplates.Where(x => x.TemplateName.ToUpper() == "CompanyUpdated".ToUpper()).FirstOrDefault(); if (updateCompany == null) { return(new BO.ErrorObject { ErrorMessage = "No record found Mail Template.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { #region Send mail to attorney string msg1 = updateCompany.EmailBody; string subject1 = updateCompany.EmailSubject; string message1 = string.Format(msg1, userDB.FirstName); BO.Email objEmail1 = new BO.Email { ToEmail = userDB.UserName, Subject = subject1, Body = message1 }; objEmail1.SendMail(); #endregion } } } catch (Exception ex) { } var res = (BO.GbObject)(object) acc_; return((object)res); }
public override object Save <T>(T entity) { BO.AdjusterMaster adjusterMasterBO = (BO.AdjusterMaster)(object) entity; BO.AddressInfo addressBO = adjusterMasterBO.AddressInfo; BO.ContactInfo contactinfoBO = adjusterMasterBO.ContactInfo; AdjusterMaster adjusterMasterDB = new AdjusterMaster(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { bool IsEditMode = false; IsEditMode = (adjusterMasterBO != null && adjusterMasterBO.ID > 0) ? true : false; AddressInfo addressDB = new AddressInfo(); ContactInfo contactinfoDB = new ContactInfo(); #region Address if (addressBO != null) { bool Add_addressDB = false; addressDB = _context.AddressInfoes.Where(p => p.id == addressBO.ID).FirstOrDefault(); if (addressDB == null && addressBO.ID <= 0) { addressDB = new AddressInfo(); Add_addressDB = true; } else if (addressDB == null && addressBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Address details dosent exists.", ErrorLevel = ErrorLevel.Error }); } addressDB.Name = IsEditMode == true && addressBO.Name == null ? addressDB.Name : addressBO.Name; addressDB.Address1 = IsEditMode == true && addressBO.Address1 == null ? addressDB.Address1 : addressBO.Address1; addressDB.Address2 = IsEditMode == true && addressBO.Address2 == null ? addressDB.Address2 : addressBO.Address2; addressDB.City = IsEditMode == true && addressBO.City == null ? addressDB.City : addressBO.City; addressDB.State = IsEditMode == true && addressBO.State == null ? addressDB.State : addressBO.State; addressDB.ZipCode = IsEditMode == true && addressBO.ZipCode == null ? addressDB.ZipCode : addressBO.ZipCode; addressDB.Country = IsEditMode == true && addressBO.Country == null ? addressDB.Country : addressBO.Country; //[STATECODE-CHANGE] // addressDB.StateCode = IsEditMode == true && addressBO.StateCode == null ? addressDB.StateCode : addressBO.StateCode; //[STATECODE-CHANGE] if (Add_addressDB == true) { addressDB = _context.AddressInfoes.Add(addressDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid address details.", ErrorLevel = ErrorLevel.Error }); } addressDB = null; } #endregion #region Contact Info if (contactinfoBO != null) { bool Add_contactinfoDB = false; contactinfoDB = _context.ContactInfoes.Where(p => p.id == contactinfoBO.ID).FirstOrDefault(); if (contactinfoDB == null && contactinfoBO.ID <= 0) { contactinfoDB = new ContactInfo(); Add_contactinfoDB = true; } else if (contactinfoDB == null && contactinfoBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Contact details dosent exists.", ErrorLevel = ErrorLevel.Error }); } contactinfoDB.Name = IsEditMode == true && contactinfoBO.Name == null ? contactinfoDB.Name : contactinfoBO.Name; contactinfoDB.CellPhone = IsEditMode == true && contactinfoBO.CellPhone == null ? contactinfoDB.CellPhone : contactinfoBO.CellPhone; contactinfoDB.EmailAddress = IsEditMode == true && contactinfoBO.EmailAddress == null ? contactinfoDB.EmailAddress : contactinfoBO.EmailAddress; contactinfoDB.HomePhone = IsEditMode == true && contactinfoBO.HomePhone == null ? contactinfoDB.HomePhone : contactinfoBO.HomePhone; contactinfoDB.WorkPhone = IsEditMode == true && contactinfoBO.WorkPhone == null ? contactinfoDB.WorkPhone : contactinfoBO.WorkPhone; contactinfoDB.FaxNo = IsEditMode == true && contactinfoBO.FaxNo == null ? contactinfoDB.FaxNo : contactinfoBO.FaxNo; contactinfoDB.IsDeleted = contactinfoBO.IsDeleted; contactinfoDB.OfficeExtension = IsEditMode == true && contactinfoBO.OfficeExtension == null ? contactinfoDB.OfficeExtension : contactinfoBO.OfficeExtension; contactinfoDB.AlternateEmail = IsEditMode == true && contactinfoBO.AlternateEmail == null ? contactinfoDB.AlternateEmail : contactinfoBO.AlternateEmail; contactinfoDB.PreferredCommunication = IsEditMode == true && contactinfoBO.PreferredCommunication == null ? contactinfoDB.PreferredCommunication : contactinfoBO.PreferredCommunication; if (Add_contactinfoDB == true) { contactinfoDB = _context.ContactInfoes.Add(contactinfoDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid contact details.", ErrorLevel = ErrorLevel.Error }); } contactinfoDB = null; } #endregion #region AdjusterMaster if (adjusterMasterBO != null) { bool Add_adjusterMasterDB = false; adjusterMasterDB = _context.AdjusterMasters.Where(p => p.Id == adjusterMasterBO.ID).FirstOrDefault(); if (adjusterMasterDB == null && adjusterMasterBO.ID <= 0) { adjusterMasterDB = new AdjusterMaster(); Add_adjusterMasterDB = true; } else if (adjusterMasterDB == null && adjusterMasterBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Adjuster information dosent exists.", ErrorLevel = ErrorLevel.Error }); } adjusterMasterDB.CompanyId = adjusterMasterBO.CompanyId; adjusterMasterDB.InsuranceMasterId = adjusterMasterBO.InsuranceMasterId; adjusterMasterDB.FirstName = IsEditMode == true && adjusterMasterBO.FirstName == null ? adjusterMasterDB.FirstName : adjusterMasterBO.FirstName; adjusterMasterDB.MiddleName = IsEditMode == true && adjusterMasterBO.MiddleName == null ? adjusterMasterDB.MiddleName : adjusterMasterBO.MiddleName; adjusterMasterDB.LastName = IsEditMode == true && adjusterMasterBO.LastName == null ? adjusterMasterDB.LastName : adjusterMasterBO.LastName; adjusterMasterDB.AddressInfoId = (addressDB != null && addressDB.id > 0) ? addressDB.id : adjusterMasterDB.AddressInfoId; adjusterMasterDB.ContactInfoId = (contactinfoDB != null && contactinfoDB.id > 0) ? contactinfoDB.id : adjusterMasterDB.ContactInfoId; if (Add_adjusterMasterDB == true) { adjusterMasterDB = _context.AdjusterMasters.Add(adjusterMasterDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid adjuster information details.", ErrorLevel = ErrorLevel.Error }); } adjusterMasterDB = null; } _context.SaveChanges(); #endregion dbContextTransaction.Commit(); adjusterMasterDB = _context.AdjusterMasters.Include("AddressInfo") .Include("ContactInfo").Include("InsuranceMaster").Where(p => p.Id == adjusterMasterDB.Id).FirstOrDefault <AdjusterMaster>(); } var res = Convert <BO.AdjusterMaster, AdjusterMaster>(adjusterMasterDB); return((object)res); }
public T ConvertUpdateCompanySignUp <T, U>(U entity) { Company company = entity as Company; if (company == null) { return(default(T)); } BO.UpdateCompany updateCompanyBO = new BO.UpdateCompany(); updateCompanyBO.Signup = new BO.Signup(); if (company != null) { if (company.IsDeleted.HasValue == false || (company.IsDeleted.HasValue == true && company.IsDeleted.Value == false)) { BO.Company boCompany = new BO.Company(); using (CompanyRepository sr = new CompanyRepository(_context)) { boCompany = sr.Convert <BO.Company, Company>(company); updateCompanyBO.Signup.company = boCompany; } } } if (company.ContactInfo != null) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.ID = company.ContactInfo.id; boContactInfo.CellPhone = company.ContactInfo.CellPhone; boContactInfo.EmailAddress = company.ContactInfo.EmailAddress; updateCompanyBO.Signup.contactInfo = boContactInfo; } if (company.UserCompanies != null) { BO.User lstUser = new BO.User(); if (company.UserCompanies.Count >= 1) { var item = company.UserCompanies.FirstOrDefault(); if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false)) { var userDB = _context.Users.Where(p => p.id == item.UserID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); using (UserRepository sr = new UserRepository(_context)) { BO.User BOUser = new BO.User(); BOUser = sr.Convert <BO.User, User>(userDB); BOUser.UserCompanies = null; BOUser.ContactInfo = null; BOUser.AddressInfo = null; BOUser.Roles = null; lstUser = BOUser; } } } updateCompanyBO.Signup.user = lstUser; } return((T)(object)updateCompanyBO); }
//public override object IsInsuranceInfoAdded(int id) //{ // var acc = _context.PatientInsuranceInfoes.Where(p => p.PatientId == id && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) // .FirstOrDefault<PatientInsuranceInfo>(); // if (acc == null) // { // return false; // } // else // { // return true; // } //} #endregion #region save public override object Save <T>(T entity) { BO.PatientInsuranceInfo insuranceBO = (BO.PatientInsuranceInfo)(object) entity; BO.AddressInfo addressinfoPolicyHolderBO = insuranceBO.AddressInfo1; BO.ContactInfo contactinfoPolicyHolderBO = insuranceBO.ContactInfo1; BO.AddressInfo addressinfoInsuranceCompanyBO = insuranceBO.AddressInfo; BO.ContactInfo contactinfoInsuranceCompanyBO = insuranceBO.ContactInfo; PatientInsuranceInfo insuranceDB = new PatientInsuranceInfo(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { bool IsEditMode = false; IsEditMode = (insuranceBO != null && insuranceBO.ID > 0) ? true : false; AddressInfo addressinfoPolicyHolderDB = new AddressInfo(); ContactInfo contactinfoPolicyHolderDB = new ContactInfo(); AddressInfo addressinfoInsuranceCompanyDB = new AddressInfo(); ContactInfo contactinfoInsuranceCompanyDB = new ContactInfo(); User userDB = new User(); #region Address Poliy Holder if (addressinfoPolicyHolderBO != null) { bool Add_addressDB = false; addressinfoPolicyHolderDB = _context.AddressInfoes.Where(p => p.id == addressinfoPolicyHolderBO.ID).FirstOrDefault(); if (addressinfoPolicyHolderDB == null && addressinfoPolicyHolderBO.ID <= 0) { addressinfoPolicyHolderDB = new AddressInfo(); Add_addressDB = true; } else if (addressinfoPolicyHolderDB == null && addressinfoPolicyHolderBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Policy address details dosent exists.", ErrorLevel = ErrorLevel.Error }); } addressinfoPolicyHolderDB.Name = IsEditMode == true && addressinfoPolicyHolderBO.Name == null ? addressinfoPolicyHolderDB.Name : addressinfoPolicyHolderBO.Name; addressinfoPolicyHolderDB.Address1 = IsEditMode == true && addressinfoPolicyHolderBO.Address1 == null ? addressinfoPolicyHolderDB.Address1 : addressinfoPolicyHolderBO.Address1; addressinfoPolicyHolderDB.Address2 = IsEditMode == true && addressinfoPolicyHolderBO.Address2 == null ? addressinfoPolicyHolderDB.Address2 : addressinfoPolicyHolderBO.Address2; addressinfoPolicyHolderDB.City = IsEditMode == true && addressinfoPolicyHolderBO.City == null ? addressinfoPolicyHolderDB.City : addressinfoPolicyHolderBO.City; addressinfoPolicyHolderDB.State = IsEditMode == true && addressinfoPolicyHolderBO.State == null ? addressinfoPolicyHolderDB.State : addressinfoPolicyHolderBO.State; addressinfoPolicyHolderDB.ZipCode = IsEditMode == true && addressinfoPolicyHolderBO.ZipCode == null ? addressinfoPolicyHolderDB.ZipCode : addressinfoPolicyHolderBO.ZipCode; addressinfoPolicyHolderDB.Country = IsEditMode == true && addressinfoPolicyHolderBO.Country == null ? addressinfoPolicyHolderDB.Country : addressinfoPolicyHolderBO.Country; //[STATECODE-CHANGE] //addressinfoPolicyHolderDB.StateCode = IsEditMode == true && addressinfoPolicyHolderBO.StateCode == null ? addressinfoPolicyHolderDB.StateCode : addressinfoPolicyHolderBO.StateCode; //[STATECODE-CHANGE] if (Add_addressDB == true) { addressinfoPolicyHolderDB = _context.AddressInfoes.Add(addressinfoPolicyHolderDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid policy address details.", ErrorLevel = ErrorLevel.Error }); } addressinfoPolicyHolderDB = null; } #endregion #region Contact Info Policy Holder if (contactinfoPolicyHolderBO != null) { bool Add_contactinfoDB = false; contactinfoPolicyHolderDB = _context.ContactInfoes.Where(p => p.id == contactinfoPolicyHolderBO.ID).FirstOrDefault(); if (contactinfoPolicyHolderDB == null && contactinfoPolicyHolderBO.ID <= 0) { contactinfoPolicyHolderDB = new ContactInfo(); Add_contactinfoDB = true; } else if (contactinfoPolicyHolderDB == null && contactinfoPolicyHolderBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Policy contact details dosent exists.", ErrorLevel = ErrorLevel.Error }); } contactinfoPolicyHolderDB.Name = IsEditMode == true && contactinfoPolicyHolderBO.Name == null ? contactinfoPolicyHolderDB.Name : contactinfoPolicyHolderBO.Name; contactinfoPolicyHolderDB.CellPhone = IsEditMode == true && contactinfoPolicyHolderBO.CellPhone == null ? contactinfoPolicyHolderDB.CellPhone : contactinfoPolicyHolderBO.CellPhone; contactinfoPolicyHolderDB.EmailAddress = IsEditMode == true && contactinfoPolicyHolderBO.EmailAddress == null ? contactinfoPolicyHolderDB.EmailAddress : contactinfoPolicyHolderBO.EmailAddress; contactinfoPolicyHolderDB.HomePhone = IsEditMode == true && contactinfoPolicyHolderBO.HomePhone == null ? contactinfoPolicyHolderDB.HomePhone : contactinfoPolicyHolderBO.HomePhone; contactinfoPolicyHolderDB.WorkPhone = IsEditMode == true && contactinfoPolicyHolderBO.WorkPhone == null ? contactinfoPolicyHolderDB.WorkPhone : contactinfoPolicyHolderBO.WorkPhone; contactinfoPolicyHolderDB.FaxNo = IsEditMode == true && contactinfoPolicyHolderBO.FaxNo == null ? contactinfoPolicyHolderDB.FaxNo : contactinfoPolicyHolderBO.FaxNo; contactinfoPolicyHolderDB.OfficeExtension = IsEditMode == true && contactinfoPolicyHolderBO.OfficeExtension == null ? contactinfoPolicyHolderDB.OfficeExtension : contactinfoPolicyHolderBO.OfficeExtension; contactinfoPolicyHolderDB.AlternateEmail = IsEditMode == true && contactinfoPolicyHolderBO.AlternateEmail == null ? contactinfoPolicyHolderDB.AlternateEmail : contactinfoPolicyHolderBO.AlternateEmail; contactinfoPolicyHolderDB.PreferredCommunication = IsEditMode == true && contactinfoPolicyHolderBO.PreferredCommunication == null ? contactinfoPolicyHolderDB.PreferredCommunication : contactinfoPolicyHolderBO.PreferredCommunication; contactinfoPolicyHolderDB.IsDeleted = contactinfoPolicyHolderBO.IsDeleted; if (Add_contactinfoDB == true) { contactinfoPolicyHolderDB = _context.ContactInfoes.Add(contactinfoPolicyHolderDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid policy contact details.", ErrorLevel = ErrorLevel.Error }); } contactinfoPolicyHolderDB = null; } #endregion #region Address Insurance Company if (addressinfoInsuranceCompanyBO != null) { bool Add_addressDB = false; addressinfoInsuranceCompanyDB = _context.AddressInfoes.Where(p => p.id == addressinfoInsuranceCompanyBO.ID).FirstOrDefault(); if (addressinfoInsuranceCompanyDB == null && addressinfoInsuranceCompanyBO.ID <= 0) { addressinfoInsuranceCompanyDB = new AddressInfo(); Add_addressDB = true; } else if (addressinfoInsuranceCompanyDB == null && addressinfoInsuranceCompanyBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Insurance address details dosent exists.", ErrorLevel = ErrorLevel.Error }); } addressinfoInsuranceCompanyDB.id = addressinfoInsuranceCompanyBO.ID; addressinfoInsuranceCompanyDB.Name = IsEditMode == true && addressinfoInsuranceCompanyBO.Name == null ? addressinfoInsuranceCompanyDB.Name : addressinfoInsuranceCompanyBO.Name; addressinfoInsuranceCompanyDB.Address1 = IsEditMode == true && addressinfoInsuranceCompanyBO.Address1 == null ? addressinfoInsuranceCompanyDB.Address1 : addressinfoInsuranceCompanyBO.Address1; addressinfoInsuranceCompanyDB.Address2 = IsEditMode == true && addressinfoInsuranceCompanyBO.Address2 == null ? addressinfoInsuranceCompanyDB.Address2 : addressinfoInsuranceCompanyBO.Address2; addressinfoInsuranceCompanyDB.City = IsEditMode == true && addressinfoInsuranceCompanyBO.City == null ? addressinfoInsuranceCompanyDB.City : addressinfoInsuranceCompanyBO.City; addressinfoInsuranceCompanyDB.State = IsEditMode == true && addressinfoInsuranceCompanyBO.State == null ? addressinfoInsuranceCompanyDB.State : addressinfoInsuranceCompanyBO.State; addressinfoInsuranceCompanyDB.ZipCode = IsEditMode == true && addressinfoInsuranceCompanyBO.ZipCode == null ? addressinfoInsuranceCompanyDB.ZipCode : addressinfoInsuranceCompanyBO.ZipCode; addressinfoInsuranceCompanyDB.Country = IsEditMode == true && addressinfoInsuranceCompanyBO.Country == null ? addressinfoInsuranceCompanyDB.Country : addressinfoInsuranceCompanyBO.Country; //[STATECODE-CHANGE] //addressinfoInsuranceCompanyDB.StateCode = IsEditMode == true && addressinfoInsuranceCompanyBO.StateCode == null ? addressinfoInsuranceCompanyDB.StateCode : addressinfoInsuranceCompanyBO.StateCode; //[STATECODE-CHANGE] if (Add_addressDB == true) { addressinfoInsuranceCompanyDB = _context.AddressInfoes.Add(addressinfoInsuranceCompanyDB); } _context.SaveChanges(); } else { //if (IsEditMode == false) //{ // dbContextTransaction.Rollback(); // return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid insurance address details.", ErrorLevel = ErrorLevel.Error }; //} addressinfoInsuranceCompanyDB = null; } #endregion #region Contact Info Insurance Company if (contactinfoInsuranceCompanyBO != null) { bool Add_contactinfoDB = false; contactinfoInsuranceCompanyDB = _context.ContactInfoes.Where(p => p.id == contactinfoInsuranceCompanyBO.ID).FirstOrDefault(); if (contactinfoInsuranceCompanyDB == null && contactinfoInsuranceCompanyBO.ID <= 0) { contactinfoInsuranceCompanyDB = new ContactInfo(); Add_contactinfoDB = true; } else if (contactinfoInsuranceCompanyDB == null && contactinfoInsuranceCompanyBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Insurance contact details dosent exists.", ErrorLevel = ErrorLevel.Error }); } contactinfoInsuranceCompanyDB.Name = IsEditMode == true && contactinfoInsuranceCompanyBO.Name == null ? contactinfoInsuranceCompanyDB.Name : contactinfoInsuranceCompanyBO.Name; contactinfoInsuranceCompanyDB.CellPhone = IsEditMode == true && contactinfoInsuranceCompanyBO.CellPhone == null ? contactinfoInsuranceCompanyDB.CellPhone : contactinfoInsuranceCompanyBO.CellPhone; contactinfoInsuranceCompanyDB.EmailAddress = IsEditMode == true && contactinfoInsuranceCompanyBO.EmailAddress == null ? contactinfoInsuranceCompanyDB.EmailAddress : contactinfoInsuranceCompanyBO.EmailAddress; contactinfoInsuranceCompanyDB.HomePhone = IsEditMode == true && contactinfoInsuranceCompanyBO.HomePhone == null ? contactinfoInsuranceCompanyDB.HomePhone : contactinfoInsuranceCompanyBO.HomePhone; contactinfoInsuranceCompanyDB.WorkPhone = IsEditMode == true && contactinfoInsuranceCompanyBO.WorkPhone == null ? contactinfoInsuranceCompanyDB.WorkPhone : contactinfoInsuranceCompanyBO.WorkPhone; contactinfoInsuranceCompanyDB.FaxNo = IsEditMode == true && contactinfoInsuranceCompanyBO.FaxNo == null ? contactinfoInsuranceCompanyDB.FaxNo : contactinfoInsuranceCompanyBO.FaxNo; contactinfoInsuranceCompanyDB.OfficeExtension = IsEditMode == true && contactinfoInsuranceCompanyBO.OfficeExtension == null ? contactinfoInsuranceCompanyDB.OfficeExtension : contactinfoInsuranceCompanyBO.OfficeExtension; contactinfoInsuranceCompanyDB.AlternateEmail = IsEditMode == true && contactinfoInsuranceCompanyBO.AlternateEmail == null ? contactinfoInsuranceCompanyDB.AlternateEmail : contactinfoInsuranceCompanyBO.AlternateEmail; contactinfoInsuranceCompanyDB.PreferredCommunication = IsEditMode == true && contactinfoInsuranceCompanyBO.PreferredCommunication == null ? contactinfoInsuranceCompanyDB.PreferredCommunication : contactinfoInsuranceCompanyBO.PreferredCommunication; contactinfoInsuranceCompanyDB.IsDeleted = contactinfoInsuranceCompanyBO.IsDeleted; if (Add_contactinfoDB == true) { contactinfoInsuranceCompanyDB = _context.ContactInfoes.Add(contactinfoInsuranceCompanyDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid insurance contact details.", ErrorLevel = ErrorLevel.Error }); } contactinfoInsuranceCompanyDB = null; } #endregion #region insurance if (insuranceBO != null) { bool Add_insuranceDB = false; insuranceDB = _context.PatientInsuranceInfoes.Where(p => p.Id == insuranceBO.ID).FirstOrDefault <PatientInsuranceInfo>(); if (insuranceDB == null && insuranceBO.ID <= 0) { insuranceDB = new PatientInsuranceInfo(); Add_insuranceDB = true; } else if (insuranceDB == null && insuranceBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Patient Insurance dosent exists.", ErrorLevel = ErrorLevel.Error }); } insuranceDB.CaseId = insuranceBO.CaseId; insuranceDB.PolicyHolderName = IsEditMode == true && insuranceBO.PolicyHoldersName == null ? insuranceDB.PolicyHolderName : insuranceBO.PolicyHoldersName; insuranceDB.PolicyHolderAddressInfoId = (addressinfoPolicyHolderDB != null && addressinfoPolicyHolderDB.id > 0) ? addressinfoPolicyHolderDB.id : insuranceDB.PolicyHolderAddressInfoId; insuranceDB.PolicyHolderContactInfoId = (contactinfoPolicyHolderDB != null && contactinfoPolicyHolderDB.id > 0) ? contactinfoPolicyHolderDB.id : insuranceDB.PolicyHolderContactInfoId; insuranceDB.PolicyOwnerId = IsEditMode == true && insuranceBO.PolicyOwnerId == null ? insuranceDB.PolicyOwnerId : insuranceBO.PolicyOwnerId; insuranceDB.InsuranceCompanyCode = IsEditMode == true && insuranceBO.InsuranceCompanyCode == null ? insuranceDB.InsuranceCompanyCode : insuranceBO.InsuranceCompanyCode; insuranceDB.InsuranceCompanyAddressInfoId = (addressinfoInsuranceCompanyDB != null && addressinfoInsuranceCompanyDB.id > 0) ? addressinfoInsuranceCompanyDB.id : insuranceDB.InsuranceCompanyAddressInfoId; insuranceDB.InsuranceCompanyContactInfoId = (contactinfoInsuranceCompanyDB != null && contactinfoInsuranceCompanyDB.id > 0) ? contactinfoInsuranceCompanyDB.id : insuranceDB.InsuranceCompanyContactInfoId; insuranceDB.PolicyNo = IsEditMode == true && insuranceBO.PolicyNo == null ? insuranceDB.PolicyNo : insuranceBO.PolicyNo; insuranceDB.ContactPerson = IsEditMode == true && insuranceBO.ContactPerson == null ? insuranceDB.ContactPerson : insuranceBO.ContactPerson; insuranceDB.InsuranceTypeId = IsEditMode == true && insuranceBO.InsuranceTypeId == null ? insuranceDB.InsuranceTypeId : insuranceBO.InsuranceTypeId; insuranceDB.IsInActive = insuranceBO.IsInActive; //insuranceDB.InsuranceMasterId = IsEditMode == true && insuranceBO.InsuranceMasterId == null ? insuranceDB.InsuranceMasterId : insuranceBO.InsuranceMasterId; InsuranceMaster InsuranceMasterDB = _context.InsuranceMasters.Where(p => insuranceBO.InsuranceMasterId.HasValue == true && p.Id == insuranceBO.InsuranceMasterId).FirstOrDefault(); if (InsuranceMasterDB != null) { insuranceDB.InsuranceMasterId = insuranceBO.InsuranceMasterId; } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Insurance Master Id.", ErrorLevel = ErrorLevel.Error }); } } if (Add_insuranceDB == true) { insuranceDB = _context.PatientInsuranceInfoes.Add(insuranceDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Patient Insurance details.", ErrorLevel = ErrorLevel.Error }); } insuranceDB = null; } _context.SaveChanges(); #endregion dbContextTransaction.Commit(); insuranceDB = _context.PatientInsuranceInfoes.Include("InsuranceMaster").Where(p => p.Id == insuranceDB.Id).FirstOrDefault <PatientInsuranceInfo>(); } var res = Convert <BO.PatientInsuranceInfo, PatientInsuranceInfo>(insuranceDB); return((object)res); }
public override object Save <T>(T entity) { BO.PreferredAttorneyProviderSignUp preferredAttorneyProviderBO = (BO.PreferredAttorneyProviderSignUp)(object) entity; PreferredAttorneyProvider preferredMedicalProviderDB = new PreferredAttorneyProvider(); BO.Company companyBO = preferredAttorneyProviderBO.Company; BO.Signup prefAttProviderBO = preferredAttorneyProviderBO.Signup; Guid invitationDB_UniqueID = Guid.NewGuid(); User userDB = new User(); UserCompany UserCompanyDB = new UserCompany(); PreferredAttorneyProvider prefAttProvider = new PreferredAttorneyProvider(); bool IsEditMode = false; IsEditMode = (preferredAttorneyProviderBO != null && preferredAttorneyProviderBO.ID > 0) ? true : false; using (var dbContextTransaction = _context.Database.BeginTransaction()) { if (companyBO == null || (companyBO != null && companyBO.ID <= 0)) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (prefAttProviderBO == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (prefAttProviderBO.company == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (prefAttProviderBO.user == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (prefAttProviderBO.contactInfo == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } //if (string.IsNullOrEmpty(prefAttProviderBO.company.TaxID) == false && _context.Companies.Any(o => o.TaxID == prefAttProviderBO.company.TaxID && (o.IsDeleted.HasValue == false || (o.IsDeleted.HasValue == true && o.IsDeleted.Value == false)))) //{ // dbContextTransaction.Rollback(); // return new BO.ErrorObject { ErrorMessage = "TaxID already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }; //} if (_context.Companies.Any(o => o.Name == prefAttProviderBO.company.Name && (o.IsDeleted.HasValue == false || (o.IsDeleted.HasValue == true && o.IsDeleted.Value == false)))) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Company already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else if (_context.Users.Any(o => o.UserName == prefAttProviderBO.user.UserName && (o.IsDeleted.HasValue == false || (o.IsDeleted.HasValue == true && o.IsDeleted.Value == false)))) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "User Name already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } BO.Company prefAttProviderCompanyBO = prefAttProviderBO.company; BO.ContactInfo ContactInfoBO = prefAttProviderBO.contactInfo; BO.User userBO = prefAttProviderBO.user; BO.Role roleBO = prefAttProviderBO.role; Company prefAttProvider_CompanyDB = new Company(); AddressInfo AddressInfo = new AddressInfo(); ContactInfo ContactInfo = new ContactInfo() { CellPhone = ContactInfoBO.CellPhone, EmailAddress = ContactInfoBO.EmailAddress }; _context.AddressInfoes.Add(AddressInfo); _context.SaveChanges(); _context.ContactInfoes.Add(ContactInfo); _context.SaveChanges(); prefAttProvider_CompanyDB.Name = prefAttProviderCompanyBO.Name; prefAttProvider_CompanyDB.Status = System.Convert.ToByte(prefAttProviderCompanyBO.Status); prefAttProvider_CompanyDB.CompanyType = System.Convert.ToByte(prefAttProviderCompanyBO.CompanyType); if (prefAttProviderCompanyBO.SubsCriptionType != null) { prefAttProvider_CompanyDB.SubscriptionPlanType = System.Convert.ToByte(prefAttProviderCompanyBO.SubsCriptionType); } else { prefAttProvider_CompanyDB.SubscriptionPlanType = null; } prefAttProvider_CompanyDB.TaxID = prefAttProviderCompanyBO.TaxID; prefAttProvider_CompanyDB.AddressId = AddressInfo.id; prefAttProvider_CompanyDB.ContactInfoID = ContactInfo.id; prefAttProvider_CompanyDB.BlobStorageTypeId = 1; prefAttProvider_CompanyDB.CompanyStatusTypeID = 1; // CompanyStatusTypeID = 1 -- RegistrationImcomplete prefAttProvider_CompanyDB.IsDeleted = prefAttProviderCompanyBO.IsDeleted; prefAttProvider_CompanyDB.CreateByUserID = prefAttProviderCompanyBO.CreateByUserID; prefAttProvider_CompanyDB.UpdateByUserID = prefAttProviderCompanyBO.UpdateByUserID; prefAttProvider_CompanyDB.CreateDate = DateTime.UtcNow; _context.Companies.Add(prefAttProvider_CompanyDB); _context.SaveChanges(); userDB.FirstName = userBO.FirstName; userDB.LastName = userBO.LastName; userDB.UserName = userBO.UserName; userDB.UserType = 3; userDB.C2FactAuthEmailEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactEmail")); userDB.C2FactAuthSMSEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactSMS")); userDB.AddressId = prefAttProvider_CompanyDB.AddressId; userDB.ContactInfoId = prefAttProvider_CompanyDB.ContactInfoID; userDB.IsDeleted = false; userDB.CreateByUserID = userBO.CreateByUserID; userDB.CreateDate = DateTime.UtcNow; _context.Users.Add(userDB); _context.SaveChanges(); UserCompanyDB.UserID = userDB.id; UserCompanyDB.CompanyID = prefAttProvider_CompanyDB.id; UserCompanyDB.UserStatusID = 1; UserCompanyDB.IsDeleted = false; UserCompanyDB.CreateByUserID = 0; UserCompanyDB.CreateDate = DateTime.UtcNow; UserCompanyDB.IsAccepted = true; _context.UserCompanies.Add(UserCompanyDB); _context.SaveChanges(); UserCompanyRole UserCompanyRoleDB = new UserCompanyRole(); UserCompanyRoleDB.UserID = userDB.id; UserCompanyRoleDB.RoleID = (int)roleBO.RoleType; UserCompanyRoleDB.IsDeleted = false; UserCompanyRoleDB.CreateDate = DateTime.UtcNow; UserCompanyRoleDB.CreateByUserID = 0; _context.UserCompanyRoles.Add(UserCompanyRoleDB); _context.SaveChanges(); prefAttProvider.PrefAttorneyProviderId = prefAttProvider_CompanyDB.id; prefAttProvider.CompanyId = companyBO.ID; prefAttProvider.IsCreated = true; prefAttProvider.IsDeleted = false; prefAttProvider.CreateByUserID = prefAttProvider_CompanyDB.CreateByUserID; prefAttProvider.UpdateByUserID = prefAttProvider_CompanyDB.UpdateByUserID; prefAttProvider.CreateDate = DateTime.UtcNow; _context.PreferredAttorneyProviders.Add(prefAttProvider); _context.SaveChanges(); dbContextTransaction.Commit(); } #region Insert Invitation Invitation invitationDB = new Invitation(); invitationDB.User = userDB; invitationDB_UniqueID = Guid.NewGuid(); invitationDB.UniqueID = invitationDB_UniqueID; invitationDB.CompanyID = UserCompanyDB.CompanyID != 0 ? UserCompanyDB.CompanyID : 0; invitationDB.CreateDate = DateTime.UtcNow; invitationDB.CreateByUserID = userDB.id; _context.Invitations.Add(invitationDB); _context.SaveChanges(); #endregion if (IsEditMode == false) { try { #region Send Email var CurrentUser = _context.Users.Where(p => p.id == prefAttProvider.CreateByUserID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault <User>(); var CurrentCompanyId = _context.UserCompanies.Where(p => p.UserID == CurrentUser.id && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).Select(p2 => p2.CompanyID).FirstOrDefault(); var CurrentCompany = _context.Companies.Where(p => p.id == CurrentCompanyId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); if (CurrentUser != null) { if (CurrentUser.UserType == 3) { var attorneyprovider_UserId = _context.UserCompanies.Where(p => p.CompanyID == prefAttProvider.PrefAttorneyProviderId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).Select(p2 => p2.UserID).FirstOrDefault(); var attorneyprovider_user = _context.Users.Where(p => p.id == attorneyprovider_UserId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); if (attorneyprovider_user != null) { var PreferredAttorneyAddByAttorney = _context.MailTemplates.Where(x => x.TemplateName.ToUpper() == "PreferredAttorneyAddByAttorney".ToUpper()).FirstOrDefault(); if (PreferredAttorneyAddByAttorney == null) { return(new BO.ErrorObject { ErrorMessage = "No record found Mail Template.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { #region Send mail to attorney string VarificationLink1 = "<a href='" + Utility.GetConfigValue("VerificationLink") + "/" + invitationDB_UniqueID + "' target='_blank'>" + Utility.GetConfigValue("VerificationLink") + "/" + invitationDB_UniqueID + "</a>"; string msg1 = PreferredAttorneyAddByAttorney.EmailBody; string subject1 = PreferredAttorneyAddByAttorney.EmailSubject; string message1 = string.Format(msg1, attorneyprovider_user.FirstName, CurrentUser.FirstName, CurrentCompany.Name, VarificationLink1); BO.Email objEmail1 = new BO.Email { ToEmail = attorneyprovider_user.UserName, Subject = subject1, Body = message1 }; objEmail1.SendMail(); #endregion } } } else if (CurrentUser.UserType == 2 || CurrentUser.UserType == 4) { var attorneyprovider_UserId = _context.UserCompanies.Where(p => p.CompanyID == prefAttProvider.PrefAttorneyProviderId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).Select(p2 => p2.UserID).FirstOrDefault(); var attorneyprovider_user = _context.Users.Where(p => p.id == attorneyprovider_UserId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); if (attorneyprovider_user != null) { var PreferredAttorneyAddByProvider = _context.MailTemplates.Where(x => x.TemplateName.ToUpper() == "PreferredAttorneyAddByProvider".ToUpper()).FirstOrDefault(); if (PreferredAttorneyAddByProvider == null) { return(new BO.ErrorObject { ErrorMessage = "No record found Mail Template.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { #region Send mail to attorney string VarificationLink1 = "<a href='" + Utility.GetConfigValue("AttorneyVerificationLink") + "/" + invitationDB_UniqueID + "' target='_blank'>" + Utility.GetConfigValue("AttorneyVerificationLink") + "/" + invitationDB_UniqueID + "</a>"; string msg1 = PreferredAttorneyAddByProvider.EmailBody; string subject1 = PreferredAttorneyAddByProvider.EmailSubject; string message1 = string.Format(msg1, attorneyprovider_user.FirstName, CurrentUser.FirstName, CurrentCompany.Name, VarificationLink1); BO.Email objEmail1 = new BO.Email { ToEmail = attorneyprovider_user.UserName, Subject = subject1, Body = message1 }; objEmail1.SendMail(); #endregion } } } } #endregion } catch (Exception ex) { } } else { #region Send Email var userId = _context.UserCompanies.Where(p => p.CompanyID == prefAttProvider.PrefAttorneyProviderId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).Select(p2 => p2.UserID).ToList(); var userBO = _context.Users.Where(p => userId.Contains(p.id) && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); if (userBO != null) { var mailTemplateDB = _context.MailTemplates.Where(x => x.TemplateName.ToUpper() == "PrefAttorneyProviderUpdated".ToUpper()).FirstOrDefault(); if (mailTemplateDB == null) { return(new BO.ErrorObject { ErrorMessage = "No record found Mail Template.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { //string VerificationLink = "<a href='" + Utility.GetConfigValue("VerificationLink") + "/" + invitationDB_UniqueID + "' target='_blank'>" + Utility.GetConfigValue("VerificationLink") + "/" + invitationDB_UniqueID + "</a>"; string LoginLink2 = "<a href='http://www.patient.codearray.tk/#/account/login'>http://www.patient.codearray.tk/#/account/login </a>"; string msg = mailTemplateDB.EmailBody; string subject = mailTemplateDB.EmailSubject; string message = string.Format(msg, userBO.FirstName, userBO.UserName, LoginLink2); BO.Email objEmail = new BO.Email { ToEmail = userBO.UserName, Subject = subject, Body = message }; objEmail.SendMail(); } } #endregion } var result = _context.PreferredAttorneyProviders.Include("Company").Include("Company1") .Where(p => p.Id == prefAttProvider.Id && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); BO.PreferredAttorneyProvider acc_ = Convert <BO.PreferredAttorneyProvider, PreferredAttorneyProvider>(result); var res = (BO.GbObject)(object) acc_; return((object)res); }
public override object UpdateAttorneyProvider <T>(T entity) { BO.PreferredAttorneyProviderSignUp preferredÀttorneyProviderBO = (BO.PreferredAttorneyProviderSignUp)(object) entity; PreferredAttorneyProvider preferredAttorneyProviderDB = new PreferredAttorneyProvider(); BO.Signup prefAttProviderBO = preferredÀttorneyProviderBO.Signup; //BO.Company company = preferredÀttorneyProviderBO.Company; PreferredAttorneyProvider prefAttProvider = new PreferredAttorneyProvider(); Guid invitationDB_UniqueID = Guid.NewGuid(); User userDB = new User(); Company prefAttProvider_CompanyDB = new Company(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { if (prefAttProviderBO == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (prefAttProviderBO.company == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (prefAttProviderBO.user == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (prefAttProviderBO.contactInfo == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "No Record Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } //if (string.IsNullOrEmpty(prefAttProviderBO.company.TaxID) == false && _context.Companies.Any(o => o.TaxID == prefAttProviderBO.company.TaxID && o.id != prefAttProviderBO.company.ID // && (o.IsDeleted.HasValue == false || (o.IsDeleted.HasValue == true && o.IsDeleted.Value == false)))) //{ // dbContextTransaction.Rollback(); // return new BO.ErrorObject { ErrorMessage = "TaxID already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }; //} if (_context.Companies.Any(o => o.Name == prefAttProviderBO.company.Name && o.id != prefAttProviderBO.company.ID && (o.IsDeleted.HasValue == false || (o.IsDeleted.HasValue == true && o.IsDeleted.Value == false)))) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Company already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else if (_context.Users.Any(o => o.UserName == prefAttProviderBO.user.UserName && o.id != prefAttProviderBO.user.ID && (o.IsDeleted.HasValue == false || (o.IsDeleted.HasValue == true && o.IsDeleted.Value == false)))) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "User Name already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } BO.Company prefAttProviderCompanyBO = prefAttProviderBO.company; BO.ContactInfo ContactInfoBO = prefAttProviderBO.contactInfo; BO.User userBO = prefAttProviderBO.user; BO.Role roleBO = prefAttProviderBO.role; prefAttProvider_CompanyDB = _context.Companies.Where(p => p.id == prefAttProviderCompanyBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (prefAttProvider_CompanyDB == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Company Record Not Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } prefAttProvider_CompanyDB.Name = prefAttProviderCompanyBO.Name; prefAttProvider_CompanyDB.Status = System.Convert.ToByte(prefAttProviderCompanyBO.Status); prefAttProvider_CompanyDB.CompanyType = System.Convert.ToByte(prefAttProviderCompanyBO.CompanyType); if (prefAttProviderCompanyBO.SubsCriptionType != null) { prefAttProvider_CompanyDB.SubscriptionPlanType = System.Convert.ToByte(prefAttProviderCompanyBO.SubsCriptionType); } else { prefAttProvider_CompanyDB.SubscriptionPlanType = null; } prefAttProvider_CompanyDB.TaxID = prefAttProviderCompanyBO.TaxID; //prefAttProvider_CompanyDB.AddressId = prefAttProviderCompanyBO.AddressInfo.ID; prefAttProvider_CompanyDB.ContactInfoID = ContactInfoBO.ID; prefAttProvider_CompanyDB.CompanyStatusTypeID = System.Convert.ToByte(prefAttProviderCompanyBO.CompanyStatusTypeID); prefAttProvider_CompanyDB.IsDeleted = false; prefAttProvider_CompanyDB.UpdateByUserID = 0; prefAttProvider_CompanyDB.UpdateDate = DateTime.UtcNow; _context.SaveChanges(); ContactInfo ContactInfo = _context.ContactInfoes.Where(p => p.id == ContactInfoBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (ContactInfo == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "Contact Record Not Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } ContactInfo.CellPhone = ContactInfoBO.CellPhone; ContactInfo.EmailAddress = ContactInfoBO.EmailAddress; _context.SaveChanges(); userDB = _context.Users.Where(p => p.id == userBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (userDB == null) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { ErrorMessage = "User Record Not Found.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } userDB.FirstName = userBO.FirstName; userDB.LastName = userBO.LastName; userDB.UserType = 3; userDB.C2FactAuthEmailEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactEmail")); userDB.C2FactAuthSMSEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactSMS")); userDB.AddressId = prefAttProvider_CompanyDB.AddressId; userDB.ContactInfoId = prefAttProvider_CompanyDB.ContactInfoID; userDB.IsDeleted = false; userDB.CreateByUserID = 0; userDB.CreateDate = DateTime.UtcNow; _context.SaveChanges(); prefAttProvider.PrefAttorneyProviderId = prefAttProviderBO.company.ID; prefAttProvider.CompanyId = preferredÀttorneyProviderBO.CompanyId; prefAttProvider.IsCreated = true; prefAttProvider.IsDeleted = false; prefAttProvider.CreateByUserID = prefAttProvider_CompanyDB.CreateByUserID; prefAttProvider.UpdateByUserID = prefAttProvider_CompanyDB.UpdateByUserID; prefAttProvider.CreateDate = DateTime.UtcNow; _context.PreferredAttorneyProviders.Add(prefAttProvider); _context.SaveChanges(); dbContextTransaction.Commit(); } try { #region Send Email var userId = _context.UserCompanies.Where(p => p.CompanyID == prefAttProvider.PrefAttorneyProviderId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).Select(p2 => p2.UserID).ToList(); var userBO = _context.Users.Where(p => userId.Contains(p.id) && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); //var userBO = _context.Users.Where(p => p.id == caseDB.AttorneyId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); if (userBO != null) { var mailTemplateDB = _context.MailTemplates.Where(x => x.TemplateName.ToUpper() == "PrefAttorneyProviderUpdated".ToUpper()).FirstOrDefault(); if (mailTemplateDB == null) { return(new BO.ErrorObject { ErrorMessage = "No record found Mail Template.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else { #region Insert Invitation Invitation invitationDB = new Invitation(); invitationDB.User = userDB; invitationDB_UniqueID = Guid.NewGuid(); invitationDB.UniqueID = invitationDB_UniqueID; invitationDB.CompanyID = prefAttProvider_CompanyDB.id != 0 ? prefAttProvider_CompanyDB.id : 0; invitationDB.CreateDate = DateTime.UtcNow; invitationDB.CreateByUserID = userDB.id; _context.Invitations.Add(invitationDB); _context.SaveChanges(); #endregion //string VerificationLink = "<a href='http://medicalprovider.codearray.tk/#/account/login'> http://medicalprovider.codearray.tk/#/account/login </a>"; string VerificationLink = "<a href='http://attorney.codearray.tk/#/account/login'> http://attorney.codearray.tk/#/account/login </a>"; string msg = mailTemplateDB.EmailBody; string subject = mailTemplateDB.EmailSubject; string message = string.Format(msg, userBO.FirstName, userBO.UserName, VerificationLink); BO.Email objEmail = new BO.Email { ToEmail = userBO.UserName, Subject = subject, Body = message }; objEmail.SendMail(); } } #endregion } catch (Exception ex) { } var result = _context.PreferredAttorneyProviders.Include("Company").Include("Company1") .Where(p => p.PrefAttorneyProviderId == prefAttProviderBO.company.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); BO.PreferredAttorneyProviderSignUp acc_ = ConvertPreferredAttorneyProviderSignUp <BO.PreferredAttorneyProviderSignUp, PreferredAttorneyProvider>(result); var res = (BO.GbObject)(object) acc_; return((object)res); }
public T ConvertPreferredAttorneyProviderSignUp <T, U>(U entity) { PreferredAttorneyProvider preferredAttorneyProviderr = entity as PreferredAttorneyProvider; if (preferredAttorneyProviderr == null) { return(default(T)); } BO.PreferredAttorneyProviderSignUp PreferredAttorneyProviderSignUpBO = new BO.PreferredAttorneyProviderSignUp(); PreferredAttorneyProviderSignUpBO.ID = preferredAttorneyProviderr.Id; PreferredAttorneyProviderSignUpBO.PrefAttorneyProviderId = preferredAttorneyProviderr.PrefAttorneyProviderId; PreferredAttorneyProviderSignUpBO.CompanyId = preferredAttorneyProviderr.CompanyId; PreferredAttorneyProviderSignUpBO.IsCreated = preferredAttorneyProviderr.IsCreated; PreferredAttorneyProviderSignUpBO.Signup = new BO.Signup(); if (preferredAttorneyProviderr.Company1 != null) { if (preferredAttorneyProviderr.Company1.IsDeleted.HasValue == false || (preferredAttorneyProviderr.Company1.IsDeleted.HasValue == true && preferredAttorneyProviderr.Company1.IsDeleted.Value == false)) { BO.Company boCompany = new BO.Company(); using (CompanyRepository sr = new CompanyRepository(_context)) { boCompany = sr.Convert <BO.Company, Company>(preferredAttorneyProviderr.Company1); PreferredAttorneyProviderSignUpBO.Signup.company = boCompany; } } } if (preferredAttorneyProviderr.Company1.ContactInfo != null) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.Name = preferredAttorneyProviderr.Company1.ContactInfo.Name; boContactInfo.CellPhone = preferredAttorneyProviderr.Company1.ContactInfo.CellPhone; boContactInfo.EmailAddress = preferredAttorneyProviderr.Company1.ContactInfo.EmailAddress; boContactInfo.HomePhone = preferredAttorneyProviderr.Company1.ContactInfo.HomePhone; boContactInfo.WorkPhone = preferredAttorneyProviderr.Company1.ContactInfo.WorkPhone; boContactInfo.FaxNo = preferredAttorneyProviderr.Company1.ContactInfo.FaxNo; boContactInfo.CreateByUserID = preferredAttorneyProviderr.Company1.ContactInfo.CreateByUserID; boContactInfo.ID = preferredAttorneyProviderr.Company1.ContactInfo.id; boContactInfo.OfficeExtension = preferredAttorneyProviderr.Company1.ContactInfo.OfficeExtension; boContactInfo.AlternateEmail = preferredAttorneyProviderr.Company1.ContactInfo.AlternateEmail; boContactInfo.PreferredCommunication = preferredAttorneyProviderr.Company1.ContactInfo.PreferredCommunication; PreferredAttorneyProviderSignUpBO.Signup.contactInfo = boContactInfo; } if (preferredAttorneyProviderr.Company1.UserCompanies != null) { BO.User lstUser = new BO.User(); if (preferredAttorneyProviderr.Company1.UserCompanies.Count >= 1) { var item = preferredAttorneyProviderr.Company1.UserCompanies.FirstOrDefault(); if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false)) { var userDB = _context.Users.Where(p => p.id == item.UserID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); using (UserRepository sr = new UserRepository(_context)) { BO.User BOUser = new BO.User(); BOUser = sr.Convert <BO.User, User>(userDB); BOUser.UserCompanies = null; BOUser.ContactInfo = null; BOUser.AddressInfo = null; BOUser.Roles = null; lstUser = BOUser; } } } PreferredAttorneyProviderSignUpBO.Signup.user = lstUser; } return((T)(object)PreferredAttorneyProviderSignUpBO); }
public override T Convert <T, U>(U entity) { PatientEmpInfo PatientEmpInfo = entity as PatientEmpInfo; if (PatientEmpInfo == null) { return(default(T)); } BO.PatientEmpInfo PatientEmpInfoBO = new BO.PatientEmpInfo(); PatientEmpInfoBO.ID = PatientEmpInfo.Id; PatientEmpInfoBO.CaseId = PatientEmpInfo.CaseId; PatientEmpInfoBO.JobTitle = PatientEmpInfo.JobTitle; PatientEmpInfoBO.EmpName = PatientEmpInfo.EmpName; PatientEmpInfoBO.AddressInfoId = PatientEmpInfo.AddressInfoId; PatientEmpInfoBO.ContactInfoId = PatientEmpInfo.ContactInfoId; PatientEmpInfoBO.Salary = PatientEmpInfo.Salary; PatientEmpInfoBO.HourOrYearly = PatientEmpInfo.HourOrYearly; PatientEmpInfoBO.LossOfEarnings = PatientEmpInfo.LossOfEarnings; PatientEmpInfoBO.DatesOutOfWork = PatientEmpInfo.DatesOutOfWork; PatientEmpInfoBO.HoursPerWeek = PatientEmpInfo.HoursPerWeek; PatientEmpInfoBO.AccidentAtEmployment = PatientEmpInfo.AccidentAtEmployment; if (PatientEmpInfo.AddressInfo != null) { if (PatientEmpInfo.AddressInfo.IsDeleted.HasValue == false || (PatientEmpInfo.AddressInfo.IsDeleted.HasValue == true && PatientEmpInfo.AddressInfo.IsDeleted.Value == false)) { BO.AddressInfo boAddress = new BO.AddressInfo(); boAddress.Name = PatientEmpInfo.AddressInfo.Name; boAddress.Address1 = PatientEmpInfo.AddressInfo.Address1; boAddress.Address2 = PatientEmpInfo.AddressInfo.Address2; boAddress.City = PatientEmpInfo.AddressInfo.City; boAddress.State = PatientEmpInfo.AddressInfo.State; boAddress.ZipCode = PatientEmpInfo.AddressInfo.ZipCode; boAddress.Country = PatientEmpInfo.AddressInfo.Country; boAddress.CreateByUserID = PatientEmpInfo.AddressInfo.CreateByUserID; boAddress.ID = PatientEmpInfo.AddressInfo.id; PatientEmpInfoBO.AddressInfo = boAddress; } } if (PatientEmpInfo.ContactInfo != null) { if (PatientEmpInfo.ContactInfo.IsDeleted.HasValue == false || (PatientEmpInfo.ContactInfo.IsDeleted.HasValue == true && PatientEmpInfo.ContactInfo.IsDeleted.Value == false)) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.Name = PatientEmpInfo.ContactInfo.Name; boContactInfo.CellPhone = PatientEmpInfo.ContactInfo.CellPhone; boContactInfo.EmailAddress = PatientEmpInfo.ContactInfo.EmailAddress; boContactInfo.HomePhone = PatientEmpInfo.ContactInfo.HomePhone; boContactInfo.WorkPhone = PatientEmpInfo.ContactInfo.WorkPhone; boContactInfo.FaxNo = PatientEmpInfo.ContactInfo.FaxNo; boContactInfo.OfficeExtension = PatientEmpInfo.ContactInfo.OfficeExtension; boContactInfo.AlternateEmail = PatientEmpInfo.ContactInfo.AlternateEmail; boContactInfo.PreferredCommunication = PatientEmpInfo.ContactInfo.PreferredCommunication; boContactInfo.CreateByUserID = PatientEmpInfo.ContactInfo.CreateByUserID; boContactInfo.ID = PatientEmpInfo.ContactInfo.id; PatientEmpInfoBO.ContactInfo = boContactInfo; } } //Common PatientEmpInfoBO.IsDeleted = PatientEmpInfo.IsDeleted; PatientEmpInfoBO.CreateByUserID = PatientEmpInfo.CreateByUserID; PatientEmpInfoBO.UpdateByUserID = PatientEmpInfo.UpdateByUserID; return((T)(object)PatientEmpInfoBO); }
public override object Save <T>(T entity) { BO.PatientEmpInfo patientEmpInfoBO = (BO.PatientEmpInfo)(object) entity; BO.AddressInfo addressBO = patientEmpInfoBO.AddressInfo; BO.ContactInfo contactinfoBO = patientEmpInfoBO.ContactInfo; PatientEmpInfo patientEmpInfoDB = new PatientEmpInfo(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { bool IsEditMode = false; IsEditMode = (patientEmpInfoBO != null && patientEmpInfoBO.ID > 0) ? true : false; AddressInfo addressDB = new AddressInfo(); ContactInfo contactinfoDB = new ContactInfo(); //User userDB = new User(); #region Address if (addressBO != null) { bool Add_addressDB = false; addressDB = _context.AddressInfoes.Where(p => p.id == addressBO.ID).FirstOrDefault(); if (addressDB == null && addressBO.ID <= 0) { addressDB = new AddressInfo(); Add_addressDB = true; } else if (addressDB == null && addressBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Address details dosent exists.", ErrorLevel = ErrorLevel.Error }); } addressDB.Name = IsEditMode == true && addressBO.Name == null ? addressDB.Name : addressBO.Name; addressDB.Address1 = IsEditMode == true && addressBO.Address1 == null ? addressDB.Address1 : addressBO.Address1; addressDB.Address2 = IsEditMode == true && addressBO.Address2 == null ? addressDB.Address2 : addressBO.Address2; addressDB.City = IsEditMode == true && addressBO.City == null ? addressDB.City : addressBO.City; addressDB.State = IsEditMode == true && addressBO.State == null ? addressDB.State : addressBO.State; addressDB.ZipCode = IsEditMode == true && addressBO.ZipCode == null ? addressDB.ZipCode : addressBO.ZipCode; addressDB.Country = IsEditMode == true && addressBO.Country == null ? addressDB.Country : addressBO.Country; //[STATECODE-CHANGE] //addressDB.StateCode = IsEditMode == true && addressBO.StateCode == null ? addressDB.StateCode : addressBO.StateCode; //[STATECODE-CHANGE] if (Add_addressDB == true) { addressDB = _context.AddressInfoes.Add(addressDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid address details.", ErrorLevel = ErrorLevel.Error }); } addressDB = null; } #endregion #region Contact Info if (contactinfoBO != null) { bool Add_contactinfoDB = false; contactinfoDB = _context.ContactInfoes.Where(p => p.id == contactinfoBO.ID).FirstOrDefault(); if (contactinfoDB == null && contactinfoBO.ID <= 0) { contactinfoDB = new ContactInfo(); Add_contactinfoDB = true; } else if (contactinfoDB == null && contactinfoBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Contact details dosent exists.", ErrorLevel = ErrorLevel.Error }); } contactinfoDB.Name = IsEditMode == true && contactinfoBO.Name == null ? contactinfoDB.Name : contactinfoBO.Name; contactinfoDB.CellPhone = IsEditMode == true && contactinfoBO.CellPhone == null ? contactinfoDB.CellPhone : contactinfoBO.CellPhone; contactinfoDB.EmailAddress = IsEditMode == true && contactinfoBO.EmailAddress == null ? contactinfoDB.EmailAddress : contactinfoBO.EmailAddress; contactinfoDB.HomePhone = IsEditMode == true && contactinfoBO.HomePhone == null ? contactinfoDB.HomePhone : contactinfoBO.HomePhone; contactinfoDB.WorkPhone = IsEditMode == true && contactinfoBO.WorkPhone == null ? contactinfoDB.WorkPhone : contactinfoBO.WorkPhone; contactinfoDB.FaxNo = IsEditMode == true && contactinfoBO.FaxNo == null ? contactinfoDB.FaxNo : contactinfoBO.FaxNo; contactinfoDB.OfficeExtension = IsEditMode == true && contactinfoBO.OfficeExtension == null ? contactinfoDB.OfficeExtension : contactinfoBO.OfficeExtension; contactinfoDB.AlternateEmail = IsEditMode == true && contactinfoBO.AlternateEmail == null ? contactinfoDB.AlternateEmail : contactinfoBO.AlternateEmail; contactinfoDB.PreferredCommunication = IsEditMode == true && contactinfoBO.PreferredCommunication == null ? contactinfoDB.PreferredCommunication : contactinfoBO.PreferredCommunication; contactinfoDB.IsDeleted = contactinfoBO.IsDeleted; if (Add_contactinfoDB == true) { contactinfoDB = _context.ContactInfoes.Add(contactinfoDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid contact details.", ErrorLevel = ErrorLevel.Error }); } contactinfoDB = null; } #endregion #region patient Emp Info if (patientEmpInfoBO != null) { bool Add_patientEmpInfoDB = false; patientEmpInfoDB = _context.PatientEmpInfoes.Where(p => p.Id == patientEmpInfoBO.ID).FirstOrDefault(); if (patientEmpInfoDB == null && patientEmpInfoBO.ID <= 0) { patientEmpInfoDB = new PatientEmpInfo(); Add_patientEmpInfoDB = true; } else if (patientEmpInfoDB == null && patientEmpInfoBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Patient employee information dosent exists.", ErrorLevel = ErrorLevel.Error }); } patientEmpInfoDB.CaseId = patientEmpInfoBO.CaseId; patientEmpInfoDB.JobTitle = IsEditMode == true && patientEmpInfoBO.JobTitle == null ? patientEmpInfoDB.JobTitle : patientEmpInfoBO.JobTitle; patientEmpInfoDB.EmpName = IsEditMode == true && patientEmpInfoBO.EmpName == null ? patientEmpInfoDB.EmpName : patientEmpInfoBO.EmpName; patientEmpInfoDB.AddressInfoId = (addressDB != null && addressDB.id > 0) ? addressDB.id : patientEmpInfoDB.AddressInfoId; patientEmpInfoDB.ContactInfoId = (contactinfoDB != null && contactinfoDB.id > 0) ? contactinfoDB.id : patientEmpInfoDB.ContactInfoId; patientEmpInfoDB.Salary = IsEditMode == true && patientEmpInfoBO.Salary == null ? patientEmpInfoDB.Salary : patientEmpInfoBO.Salary; patientEmpInfoDB.HourOrYearly = IsEditMode == true && patientEmpInfoBO.HourOrYearly == null ? patientEmpInfoDB.HourOrYearly : patientEmpInfoBO.HourOrYearly; patientEmpInfoDB.LossOfEarnings = IsEditMode == true && patientEmpInfoBO.LossOfEarnings == null ? patientEmpInfoDB.LossOfEarnings : patientEmpInfoBO.LossOfEarnings; patientEmpInfoDB.DatesOutOfWork = IsEditMode == true && patientEmpInfoBO.DatesOutOfWork == null ? patientEmpInfoDB.DatesOutOfWork : patientEmpInfoBO.DatesOutOfWork; patientEmpInfoDB.HoursPerWeek = IsEditMode == true && patientEmpInfoBO.HoursPerWeek == null ? patientEmpInfoDB.HoursPerWeek : patientEmpInfoBO.HoursPerWeek; patientEmpInfoDB.AccidentAtEmployment = IsEditMode == true && patientEmpInfoBO.AccidentAtEmployment == null ? patientEmpInfoDB.AccidentAtEmployment : patientEmpInfoBO.AccidentAtEmployment; if (Add_patientEmpInfoDB == true) { patientEmpInfoDB = _context.PatientEmpInfoes.Add(patientEmpInfoDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid patient employee information details.", ErrorLevel = ErrorLevel.Error }); } patientEmpInfoDB = null; } _context.SaveChanges(); #endregion dbContextTransaction.Commit(); patientEmpInfoDB = _context.PatientEmpInfoes.Include("addressInfo").Include("contactInfo").Where(p => p.Id == patientEmpInfoDB.Id).FirstOrDefault <PatientEmpInfo>(); } var res = Convert <BO.PatientEmpInfo, PatientEmpInfo>(patientEmpInfoDB); return((object)res); }
public override T Convert <T, U>(U entity) { List <InsuranceMaster> insuranceMaster = entity as List <InsuranceMaster>; if (insuranceMaster == null) { return(default(T)); } List <BO.InsuranceMaster> boInsuranceMasters = new List <BO.InsuranceMaster>(); foreach (var eachInsuranceMaster in insuranceMaster) { BO.InsuranceMaster boInsuranceMaster = new BO.InsuranceMaster(); boInsuranceMaster.ID = eachInsuranceMaster.Id; boInsuranceMaster.CompanyCode = eachInsuranceMaster.CompanyCode; boInsuranceMaster.CompanyName = eachInsuranceMaster.CompanyName; boInsuranceMaster.AddressInfoId = eachInsuranceMaster.AddressInfoId; boInsuranceMaster.ContactInfoId = eachInsuranceMaster.ContactInfoId; boInsuranceMaster.ZeusID = eachInsuranceMaster.ZeusID; boInsuranceMaster.PriorityBilling = eachInsuranceMaster.PriorityBilling; boInsuranceMaster.Only1500Form = eachInsuranceMaster.Only1500Form; boInsuranceMaster.PaperAuthorization = eachInsuranceMaster.PaperAuthorization; boInsuranceMaster.CreatedByCompanyId = eachInsuranceMaster.CreatedByCompanyId; //if (eachInsuranceMaster.IsDeleted.HasValue) // boInsuranceMaster.IsDeleted = eachInsuranceMaster.IsDeleted.Value; if (eachInsuranceMaster.AddressInfo != null) { BO.AddressInfo boAddress = new BO.AddressInfo(); boAddress.Name = eachInsuranceMaster.AddressInfo.Name; boAddress.Address1 = eachInsuranceMaster.AddressInfo.Address1; boAddress.Address2 = eachInsuranceMaster.AddressInfo.Address2; boAddress.City = eachInsuranceMaster.AddressInfo.City; boAddress.State = eachInsuranceMaster.AddressInfo.State; boAddress.ZipCode = eachInsuranceMaster.AddressInfo.ZipCode; boAddress.Country = eachInsuranceMaster.AddressInfo.Country; //[STATECODE-CHANGE] //boAddress.StateCode = eachInsuranceMaster.AddressInfo.StateCode; //[STATECODE-CHANGE] boAddress.CreateByUserID = eachInsuranceMaster.AddressInfo.CreateByUserID; boAddress.ID = eachInsuranceMaster.AddressInfo.id; boInsuranceMaster.AddressInfo = boAddress; } if (eachInsuranceMaster.ContactInfo != null) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.Name = eachInsuranceMaster.ContactInfo.Name; boContactInfo.CellPhone = eachInsuranceMaster.ContactInfo.CellPhone; boContactInfo.EmailAddress = eachInsuranceMaster.ContactInfo.EmailAddress; boContactInfo.HomePhone = eachInsuranceMaster.ContactInfo.HomePhone; boContactInfo.WorkPhone = eachInsuranceMaster.ContactInfo.WorkPhone; boContactInfo.FaxNo = eachInsuranceMaster.ContactInfo.FaxNo; boContactInfo.CreateByUserID = eachInsuranceMaster.ContactInfo.CreateByUserID; boContactInfo.ID = eachInsuranceMaster.ContactInfo.id; boContactInfo.OfficeExtension = eachInsuranceMaster.ContactInfo.OfficeExtension; boContactInfo.AlternateEmail = eachInsuranceMaster.ContactInfo.AlternateEmail; boContactInfo.PreferredCommunication = eachInsuranceMaster.ContactInfo.PreferredCommunication; boInsuranceMaster.ContactInfo = boContactInfo; } boInsuranceMaster.IsDeleted = eachInsuranceMaster.IsDeleted; boInsuranceMaster.CreateByUserID = eachInsuranceMaster.CreateByUserID; boInsuranceMaster.UpdateByUserID = eachInsuranceMaster.UpdateByUserID; boInsuranceMasters.Add(boInsuranceMaster); } return((T)(object)boInsuranceMasters); }
public override Object Signup <T>(T data) { BO.Signup signUPBO = (BO.Signup)(object) data; bool flagUser = false; BO.User userBO = signUPBO.user; BO.Company companyBO = signUPBO.company; BO.AddressInfo addressBO = signUPBO.addressInfo; BO.ContactInfo contactinfoBO = signUPBO.contactInfo; BO.Role roleBO = signUPBO.role; Company companyDB = new Company(); User userDB = new User(); AddressInfo addressDB = new AddressInfo(); ContactInfo contactinfoDB = new ContactInfo(); UserCompany userCompanyDB = new UserCompany(); UserCompanyRole userCompanyRoleDB = new UserCompanyRole(); Invitation invitationDB = new Invitation(); if (string.IsNullOrEmpty(companyBO.TaxID) == false && _context.Companies.Any(o => o.TaxID == companyBO.TaxID)) { return(new BO.ErrorObject { ErrorMessage = "TaxID already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (_context.Companies.Any(o => o.Name == companyBO.Name)) { return(new BO.ErrorObject { ErrorMessage = "Company already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error }); } else if (_context.Users.Any(o => o.UserName == userBO.UserName)) { flagUser = true; } #region Company companyDB.Name = companyBO.Name; companyDB.id = companyBO.ID; companyDB.TaxID = companyBO.TaxID; companyDB.Status = System.Convert.ToByte(companyBO.Status); companyDB.CompanyType = System.Convert.ToByte(companyBO.CompanyType); if (companyBO.SubsCriptionType.HasValue == true) { companyDB.SubscriptionPlanType = System.Convert.ToInt16(companyBO.SubsCriptionType); } else { companyDB.SubscriptionPlanType = null; } companyDB.CompanyStatusTypeID = 2; // CompanyStatusTypeID = 2 --- RegistrationComplete companyDB.BlobStorageTypeId = 1; if (companyDB.IsDeleted.HasValue) { companyDB.IsDeleted = companyBO.IsDeleted.Value; } #endregion #region Address if (addressBO != null) { addressDB.id = addressBO.ID; addressDB.Name = addressBO.Name; addressDB.Address1 = addressBO.Address1; addressDB.Address2 = addressBO.Address2; addressDB.City = addressBO.City; addressDB.State = addressBO.State; addressDB.ZipCode = addressBO.ZipCode; addressDB.Country = addressBO.Country; } #endregion #region Contact Info if (contactinfoBO != null) { contactinfoDB.id = contactinfoBO.ID; contactinfoDB.Name = contactinfoBO.Name; contactinfoDB.CellPhone = contactinfoBO.CellPhone; contactinfoDB.EmailAddress = contactinfoBO.EmailAddress; contactinfoDB.HomePhone = contactinfoBO.HomePhone; contactinfoDB.WorkPhone = contactinfoBO.WorkPhone; contactinfoDB.FaxNo = contactinfoBO.FaxNo; if (contactinfoBO.IsDeleted.HasValue) { contactinfoDB.IsDeleted = contactinfoBO.IsDeleted; } } #endregion #region User if (!flagUser) { userDB.UserName = userBO.UserName; userDB.MiddleName = userBO.MiddleName; userDB.FirstName = userBO.FirstName; userDB.LastName = userBO.LastName; userDB.Gender = System.Convert.ToByte(userBO.Gender); userDB.UserType = System.Convert.ToByte(userBO.UserType); userDB.C2FactAuthEmailEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactEmail")); userDB.C2FactAuthSMSEnabled = System.Convert.ToBoolean(Utility.GetConfigValue("Default2FactSMS")); userDB.ImageLink = userBO.ImageLink; if (userBO.DateOfBirth.HasValue) { userDB.DateOfBirth = userBO.DateOfBirth.Value; } if (userBO.IsDeleted.HasValue) { userDB.IsDeleted = userBO.IsDeleted.Value; } userDB.AddressInfo = addressDB; userDB.ContactInfo = contactinfoDB; userCompanyDB.User = userDB; userCompanyDB.IsAccepted = true; } else { //Find Record By Name User user_ = _context.Users.Where(p => p.UserName == userBO.UserName).FirstOrDefault <User>(); userCompanyDB.User = user_; userCompanyDB.IsAccepted = true; _context.Entry(user_).State = System.Data.Entity.EntityState.Modified; } #endregion UserCompany cmp = new UserCompany(); cmp.Company = companyDB; companyDB.AddressInfo = addressDB; companyDB.ContactInfo = contactinfoDB; if (companyDB.id > 0) { //For Update Record } else { companyDB.CreateDate = companyBO.CreateDate; companyDB.CreateByUserID = companyBO.CreateByUserID; userDB.CreateDate = companyBO.CreateDate; userDB.CreateByUserID = companyBO.CreateByUserID; addressDB.CreateDate = companyBO.CreateDate; addressDB.CreateByUserID = companyBO.CreateByUserID; contactinfoDB.CreateDate = companyBO.CreateDate; contactinfoDB.CreateByUserID = companyBO.CreateByUserID; _dbSet.Add(companyDB); } _context.SaveChanges(); #region Insert User Block userCompanyDB.IsAccepted = true; userCompanyDB.Company = companyDB; userCompanyDB.UserStatusID = 1; //UserStatusID = 1 --- UserStatus Pending userCompanyDB.CreateDate = companyBO.CreateDate; userCompanyDB.CreateByUserID = companyBO.CreateByUserID; _dbUserCompany.Add(userCompanyDB); _context.SaveChanges(); #endregion #region Insert User Company Role userCompanyRoleDB.User = userCompanyDB.User; userCompanyRoleDB.RoleID = (int)roleBO.RoleType; userCompanyRoleDB.CreateDate = companyBO.CreateDate; userCompanyRoleDB.CreateByUserID = companyBO.CreateByUserID; _dbUserCompanyRole.Add(userCompanyRoleDB); _context.SaveChanges(); #endregion #region Insert Invitation invitationDB.User = userCompanyDB.User; invitationDB.Company = companyDB; invitationDB.UniqueID = Guid.NewGuid(); invitationDB.CreateDate = companyBO.CreateDate; invitationDB.CreateByUserID = companyBO.CreateByUserID; _dbInvitation.Add(invitationDB); _context.SaveChanges(); #endregion #region Update referral //var referral = _context.Referrals.Where(p => p.ReferredToEmail == userDB.UserName && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).ToList<Referral>(); //foreach (var eachReferral in referral) //{ // eachReferral.ReferredToCompanyId = companyDB.id; // eachReferral.ReferralAccepted = true; //} _context.SaveChanges(); #endregion BO.Company acc_ = Convert <BO.Company, Company>(companyDB); try { #region Send Email string VerificationLink = "<a href='" + Utility.GetConfigValue("VerificationLink") + "/" + invitationDB.UniqueID + "' target='_blank'>" + Utility.GetConfigValue("VerificationLink") + "/" + invitationDB.UniqueID + "</a>"; string Message = "Dear " + userBO.FirstName + ",<br><br>Thanks for registering with us.<br><br> Your user name is:- " + userBO.UserName + "<br><br> Please confirm your account by clicking below link in order to use.<br><br><b>" + VerificationLink + "</b><br><br>Thanks"; BO.Email objEmail = new BO.Email { ToEmail = userBO.UserName, Subject = "Company registered", Body = Message }; objEmail.SendMail(); #endregion } catch (Exception ex) { //Message sending failed } var res = (BO.GbObject)(object) acc_; return((object)res); }
public override object Save <T>(T entity) { BO.InsuranceMaster insuranceMasterBO = (BO.InsuranceMaster)(object) entity; BO.AddressInfo addressBO = insuranceMasterBO.AddressInfo; BO.ContactInfo contactinfoBO = insuranceMasterBO.ContactInfo; if (insuranceMasterBO.CreatedByCompanyId.HasValue == true) { InsuranceMaster insuranceMasterDB = new InsuranceMaster(); using (var dbContextTransaction = _context.Database.BeginTransaction()) { bool IsEditMode = false; IsEditMode = (insuranceMasterBO != null && insuranceMasterBO.ID > 0) ? true : false; AddressInfo addressDB = new AddressInfo(); ContactInfo contactinfoDB = new ContactInfo(); #region Address if (addressBO != null) { bool Add_addressDB = false; addressDB = _context.AddressInfoes.Where(p => p.id == addressBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); if (addressDB == null && addressBO.ID <= 0) { addressDB = new AddressInfo(); Add_addressDB = true; } else if (addressDB == null && addressBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Address details dosent exists.", ErrorLevel = ErrorLevel.Error }); } addressDB.Name = IsEditMode == true && addressBO.Name == null ? addressDB.Name : addressBO.Name; addressDB.Address1 = IsEditMode == true && addressBO.Address1 == null ? addressDB.Address1 : addressBO.Address1; addressDB.Address2 = IsEditMode == true && addressBO.Address2 == null ? addressDB.Address2 : addressBO.Address2; addressDB.City = IsEditMode == true && addressBO.City == null ? addressDB.City : addressBO.City; addressDB.State = IsEditMode == true && addressBO.State == null ? addressDB.State : addressBO.State; addressDB.ZipCode = IsEditMode == true && addressBO.ZipCode == null ? addressDB.ZipCode : addressBO.ZipCode; addressDB.Country = IsEditMode == true && addressBO.Country == null ? addressDB.Country : addressBO.Country; //[STATECODE-CHANGE] //addressDB.StateCode = IsEditMode == true && addressBO.StateCode == null ? addressDB.StateCode : addressBO.StateCode; //[STATECODE-CHANGE] if (Add_addressDB == true) { addressDB = _context.AddressInfoes.Add(addressDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid address details.", ErrorLevel = ErrorLevel.Error }); } addressDB = null; } #endregion #region Contact Info if (contactinfoBO != null) { bool Add_contactinfoDB = false; contactinfoDB = _context.ContactInfoes.Where(p => p.id == contactinfoBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault(); if (contactinfoDB == null && contactinfoBO.ID <= 0) { contactinfoDB = new ContactInfo(); Add_contactinfoDB = true; } else if (contactinfoDB == null && contactinfoBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Contact details dosent exists.", ErrorLevel = ErrorLevel.Error }); } contactinfoDB.Name = IsEditMode == true && contactinfoBO.Name == null ? contactinfoDB.Name : contactinfoBO.Name; contactinfoDB.CellPhone = IsEditMode == true && contactinfoBO.CellPhone == null ? contactinfoDB.CellPhone : contactinfoBO.CellPhone; contactinfoDB.EmailAddress = IsEditMode == true && contactinfoBO.EmailAddress == null ? contactinfoDB.EmailAddress : contactinfoBO.EmailAddress; contactinfoDB.HomePhone = IsEditMode == true && contactinfoBO.HomePhone == null ? contactinfoDB.HomePhone : contactinfoBO.HomePhone; contactinfoDB.WorkPhone = IsEditMode == true && contactinfoBO.WorkPhone == null ? contactinfoDB.WorkPhone : contactinfoBO.WorkPhone; contactinfoDB.FaxNo = IsEditMode == true && contactinfoBO.FaxNo == null ? contactinfoDB.FaxNo : contactinfoBO.FaxNo; contactinfoDB.OfficeExtension = IsEditMode == true && contactinfoBO.OfficeExtension == null ? contactinfoDB.OfficeExtension : contactinfoBO.OfficeExtension; contactinfoDB.AlternateEmail = IsEditMode == true && contactinfoBO.AlternateEmail == null ? contactinfoDB.AlternateEmail : contactinfoBO.AlternateEmail; contactinfoDB.PreferredCommunication = IsEditMode == true && contactinfoBO.PreferredCommunication == null ? contactinfoDB.PreferredCommunication : contactinfoBO.PreferredCommunication; contactinfoDB.IsDeleted = contactinfoBO.IsDeleted; if (Add_contactinfoDB == true) { contactinfoDB = _context.ContactInfoes.Add(contactinfoDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid contact details.", ErrorLevel = ErrorLevel.Error }); } contactinfoDB = null; } #endregion #region Insurance Master if (insuranceMasterBO != null) { bool Add_insuranceMasterDB = false; insuranceMasterDB = _context.InsuranceMasters.Where(p => p.Id == insuranceMasterBO.ID && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault <InsuranceMaster>(); if (insuranceMasterDB == null && insuranceMasterBO.ID <= 0) { insuranceMasterDB = new InsuranceMaster(); Add_insuranceMasterDB = true; } else if (insuranceMasterDB == null && insuranceMasterBO.ID > 0) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Insurance Master information dosent exists.", ErrorLevel = ErrorLevel.Error }); } insuranceMasterDB.CompanyCode = insuranceMasterBO.CompanyCode; insuranceMasterDB.CompanyName = IsEditMode == true && insuranceMasterBO.CompanyName == null ? insuranceMasterDB.CompanyName : insuranceMasterBO.CompanyName; insuranceMasterDB.ZeusID = insuranceMasterBO.ZeusID; insuranceMasterDB.PriorityBilling = insuranceMasterBO.PriorityBilling; insuranceMasterDB.Only1500Form = insuranceMasterBO.Only1500Form; insuranceMasterDB.PaperAuthorization = insuranceMasterBO.PaperAuthorization; insuranceMasterDB.CreatedByCompanyId = insuranceMasterBO.CreatedByCompanyId; insuranceMasterDB.AddressInfoId = (addressDB != null && addressDB.id > 0) ? addressDB.id : insuranceMasterDB.AddressInfoId; insuranceMasterDB.ContactInfoId = (contactinfoDB != null && contactinfoDB.id > 0) ? contactinfoDB.id : insuranceMasterDB.ContactInfoId; if (Add_insuranceMasterDB == true) { insuranceMasterDB = _context.InsuranceMasters.Add(insuranceMasterDB); } _context.SaveChanges(); } else { if (IsEditMode == false) { dbContextTransaction.Rollback(); return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid insurance master information details.", ErrorLevel = ErrorLevel.Error }); } insuranceMasterDB = null; } _context.SaveChanges(); #endregion dbContextTransaction.Commit(); insuranceMasterDB = _context.InsuranceMasters.Include("addressInfo").Include("contactInfo").Where(p => p.Id == insuranceMasterDB.Id && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault <InsuranceMaster>(); } var res = ObjectConvert <BO.InsuranceMaster, InsuranceMaster>(insuranceMasterDB); return((object)res); } else { return(new BO.ErrorObject { errorObject = "", ErrorMessage = "Cannot add or update Master Insurance data.", ErrorLevel = ErrorLevel.Error }); } }
public override T Convert <T, U>(U entity) { PatientInsuranceInfo InsuranceInfos = entity as PatientInsuranceInfo; if (InsuranceInfos == null) { return(default(T)); } BO.PatientInsuranceInfo insuranceBO = new BO.PatientInsuranceInfo(); insuranceBO.ID = InsuranceInfos.Id; insuranceBO.CaseId = InsuranceInfos.CaseId; insuranceBO.PolicyHoldersName = InsuranceInfos.PolicyHolderName; insuranceBO.PolicyHolderAddressInfoId = InsuranceInfos.PolicyHolderAddressInfoId; insuranceBO.PolicyHolderContactInfoId = InsuranceInfos.PolicyHolderContactInfoId; insuranceBO.PolicyOwnerId = InsuranceInfos.PolicyOwnerId; insuranceBO.InsuranceMasterId = InsuranceInfos.InsuranceMasterId; insuranceBO.InsuranceCompanyCode = InsuranceInfos.InsuranceCompanyCode; insuranceBO.InsuranceCompanyAddressInfoId = InsuranceInfos.InsuranceCompanyAddressInfoId; insuranceBO.InsuranceCompanyContactInfoId = InsuranceInfos.InsuranceCompanyContactInfoId; insuranceBO.PolicyNo = InsuranceInfos.PolicyNo; insuranceBO.ContactPerson = InsuranceInfos.ContactPerson; insuranceBO.InsuranceTypeId = InsuranceInfos.InsuranceTypeId; insuranceBO.IsInActive = InsuranceInfos.IsInActive; if (InsuranceInfos.AddressInfo != null) { if (InsuranceInfos.AddressInfo.IsDeleted.HasValue == false || (InsuranceInfos.AddressInfo.IsDeleted.HasValue == true && InsuranceInfos.AddressInfo.IsDeleted.Value == false)) { BO.AddressInfo boAddress = new BO.AddressInfo(); boAddress.Name = InsuranceInfos.AddressInfo.Name; boAddress.Address1 = InsuranceInfos.AddressInfo.Address1; boAddress.Address2 = InsuranceInfos.AddressInfo.Address2; boAddress.City = InsuranceInfos.AddressInfo.City; boAddress.State = InsuranceInfos.AddressInfo.State; boAddress.ZipCode = InsuranceInfos.AddressInfo.ZipCode; boAddress.Country = InsuranceInfos.AddressInfo.Country; //[STATECODE-CHANGE] //boAddress.StateCode = InsuranceInfos.AddressInfo.StateCode; //[STATECODE-CHANGE] boAddress.CreateByUserID = InsuranceInfos.AddressInfo.CreateByUserID; boAddress.ID = InsuranceInfos.AddressInfo.id; insuranceBO.AddressInfo = boAddress; } } if (InsuranceInfos.ContactInfo != null) { if (InsuranceInfos.ContactInfo.IsDeleted.HasValue == false || (InsuranceInfos.ContactInfo.IsDeleted.HasValue == true && InsuranceInfos.ContactInfo.IsDeleted.Value == false)) { BO.ContactInfo boContactInfo = new BO.ContactInfo(); boContactInfo.Name = InsuranceInfos.ContactInfo.Name; boContactInfo.CellPhone = InsuranceInfos.ContactInfo.CellPhone; boContactInfo.EmailAddress = InsuranceInfos.ContactInfo.EmailAddress; boContactInfo.HomePhone = InsuranceInfos.ContactInfo.HomePhone; boContactInfo.WorkPhone = InsuranceInfos.ContactInfo.WorkPhone; boContactInfo.FaxNo = InsuranceInfos.ContactInfo.FaxNo; boContactInfo.OfficeExtension = InsuranceInfos.ContactInfo.OfficeExtension; boContactInfo.AlternateEmail = InsuranceInfos.ContactInfo.AlternateEmail; boContactInfo.PreferredCommunication = InsuranceInfos.ContactInfo.PreferredCommunication; boContactInfo.CreateByUserID = InsuranceInfos.ContactInfo.CreateByUserID; boContactInfo.ID = InsuranceInfos.ContactInfo.id; insuranceBO.ContactInfo = boContactInfo; } } if (InsuranceInfos.AddressInfo1 != null) { if (InsuranceInfos.AddressInfo1.IsDeleted.HasValue == false || (InsuranceInfos.AddressInfo1.IsDeleted.HasValue == true && InsuranceInfos.AddressInfo1.IsDeleted.Value == false)) { BO.AddressInfo boAddress1 = new BO.AddressInfo(); boAddress1.Name = InsuranceInfos.AddressInfo1.Name; boAddress1.Address1 = InsuranceInfos.AddressInfo1.Address1; boAddress1.Address2 = InsuranceInfos.AddressInfo1.Address2; boAddress1.City = InsuranceInfos.AddressInfo1.City; boAddress1.State = InsuranceInfos.AddressInfo1.State; boAddress1.ZipCode = InsuranceInfos.AddressInfo1.ZipCode; boAddress1.Country = InsuranceInfos.AddressInfo1.Country; //[STATECODE-CHANGE] //boAddress1.StateCode = InsuranceInfos.AddressInfo1.StateCode; //[STATECODE-CHANGE] boAddress1.CreateByUserID = InsuranceInfos.AddressInfo1.CreateByUserID; boAddress1.ID = InsuranceInfos.AddressInfo1.id; insuranceBO.AddressInfo1 = boAddress1; } } if (InsuranceInfos.ContactInfo1 != null) { if (InsuranceInfos.ContactInfo1.IsDeleted.HasValue == false || (InsuranceInfos.ContactInfo1.IsDeleted.HasValue == true && InsuranceInfos.ContactInfo1.IsDeleted.Value == false)) { BO.ContactInfo boContactInfo1 = new BO.ContactInfo(); boContactInfo1.Name = InsuranceInfos.ContactInfo1.Name; boContactInfo1.CellPhone = InsuranceInfos.ContactInfo1.CellPhone; boContactInfo1.EmailAddress = InsuranceInfos.ContactInfo1.EmailAddress; boContactInfo1.HomePhone = InsuranceInfos.ContactInfo1.HomePhone; boContactInfo1.WorkPhone = InsuranceInfos.ContactInfo1.WorkPhone; boContactInfo1.FaxNo = InsuranceInfos.ContactInfo1.FaxNo; boContactInfo1.OfficeExtension = InsuranceInfos.ContactInfo1.OfficeExtension; boContactInfo1.AlternateEmail = InsuranceInfos.ContactInfo1.AlternateEmail; boContactInfo1.PreferredCommunication = InsuranceInfos.ContactInfo1.PreferredCommunication; boContactInfo1.CreateByUserID = InsuranceInfos.ContactInfo1.CreateByUserID; boContactInfo1.ID = InsuranceInfos.ContactInfo1.id; insuranceBO.ContactInfo1 = boContactInfo1; } } if (InsuranceInfos.InsuranceMaster != null) { if (InsuranceInfos.InsuranceMaster.IsDeleted.HasValue == false || (InsuranceInfos.InsuranceMaster.IsDeleted.HasValue == true && InsuranceInfos.InsuranceMaster.IsDeleted.Value == false)) { BO.InsuranceMaster boInsuranceMaster = new BO.InsuranceMaster(); using (InsuranceMasterRepository cmp = new InsuranceMasterRepository(_context)) { boInsuranceMaster = cmp.ObjectConvert <BO.InsuranceMaster, InsuranceMaster>(InsuranceInfos.InsuranceMaster); insuranceBO.InsuranceMaster = boInsuranceMaster; } } } if (InsuranceInfos.InsuranceType != null) { if (InsuranceInfos.InsuranceType.IsDeleted.HasValue == false || (InsuranceInfos.InsuranceType.IsDeleted.HasValue == true && InsuranceInfos.InsuranceType.IsDeleted.Value == false)) { BO.InsuranceType boInsuranceType = new BO.InsuranceType(); boInsuranceType.InsuranceTypeText = InsuranceInfos.InsuranceType.InsuranceTypeText; insuranceBO.InsuranceType = boInsuranceType; } } insuranceBO.IsDeleted = InsuranceInfos.IsDeleted; insuranceBO.CreateByUserID = InsuranceInfos.CreateByUserID; insuranceBO.UpdateByUserID = InsuranceInfos.UpdateByUserID; return((T)(object)insuranceBO); }