public override T Convert <T, U>(U entity) { BO.User boUser = new BO.User(); BO.Company boCompany = new BO.Company(); Invitation invitation = entity as Invitation; if (invitation == null) { return(default(T)); } BO.Invitation boInvitation = new BO.Invitation(); boUser.ID = invitation.UserID; boInvitation.InvitationID = invitation.InvitationID; boInvitation.User = boUser; if (invitation.User.UserCompanies != null && invitation.User.UserCompanies.Count > 0) { List <BO.UserCompany> boUserCompany = new List <BO.UserCompany>(); invitation.User.UserCompanies.Where(p => p.IsAccepted == true && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .ToList().ForEach(x => boUserCompany.Add(new BO.UserCompany() { CompanyId = x.CompanyID, UserId = x.UserID, UserStatusID = (BO.GBEnums.UserStatu)x.UserStatusID, CreateByUserID = x.CreateByUserID, ID = x.id, IsDeleted = x.IsDeleted, UpdateByUserID = x.UpdateByUserID })); boInvitation.User.UserCompanies = boUserCompany; } boCompany.ID = invitation.CompanyID; boInvitation.Company = boCompany; return((T)(object)boInvitation); }
public T CompanyConvert <T, U>(U entity) { Company company = entity as Company; if (company == null) { return(default(T)); } BO.Company boCompany = new BO.Company(); boCompany.ID = company.id; boCompany.Name = company.Name; boCompany.TaxID = company.TaxID; boCompany.Status = (BO.GBEnums.AccountStatus)company.Status; boCompany.CompanyType = (BO.GBEnums.CompanyType)company.CompanyType; if (company.SubscriptionPlanType != null) { boCompany.SubsCriptionType = (BO.GBEnums.SubsCriptionType)company.SubscriptionPlanType; } else { boCompany.SubsCriptionType = null; } boCompany.CompanyStatusTypeID = (BO.GBEnums.CompanyStatusType)company.CompanyStatusTypeID; boCompany.IsDeleted = company.IsDeleted; boCompany.CreateByUserID = company.CreateByUserID; boCompany.UpdateByUserID = company.UpdateByUserID; return((T)(object)boCompany); }
public override T Convert <T, U>(U entity) { if (entity.GetType().Name == "Invitation") { BO.User boUser = new BO.User(); Invitation invitation = entity as Invitation; if (invitation == null) { return(default(T)); } BO.Invitation boInvitation = new BO.Invitation(); boUser.ID = invitation.UserID; boInvitation.InvitationID = invitation.InvitationID; boInvitation.User = boUser; return((T)(object)boInvitation); } else { Company company = entity as Company; if (company == null) { return(default(T)); } BO.Company boCompany = new BO.Company(); boCompany.ID = company.id; boCompany.Name = company.Name; boCompany.TaxID = company.TaxID == null ? null : company.TaxID; boCompany.Status = (BO.GBEnums.AccountStatus)company.Status; boCompany.CompanyType = (BO.GBEnums.CompanyType)company.CompanyType; if (company.SubscriptionPlanType != null) { boCompany.SubsCriptionType = (BO.GBEnums.SubsCriptionType)company.SubscriptionPlanType; } else { boCompany.SubsCriptionType = null; } boCompany.CompanyStatusTypeID = (BO.GBEnums.CompanyStatusType)company.CompanyStatusTypeID; if (company.Locations != null) { List <BO.Location> lstLocation = new List <BO.Location>(); foreach (var item in company.Locations) { using (LocationRepository sr = new LocationRepository(_context)) { BO.Location location = sr.Convert <BO.Location, Location>(item); location.Company = null; lstLocation.Add(location); } } boCompany.Locations = lstLocation; } return((T)(object)boCompany); } }
public override T Convert <T, U>(U entity) { GeneralSetting generalSetting = entity as GeneralSetting; if (generalSetting == null) { return(default(T)); } BO.GeneralSetting generalSettingBO = new BO.GeneralSetting(); generalSettingBO.ID = generalSetting.Id; generalSettingBO.CompanyId = generalSetting.CompanyId; generalSettingBO.SlotDuration = generalSetting.SlotDuration; generalSettingBO.IsDeleted = generalSetting.IsDeleted; generalSettingBO.CreateByUserID = generalSetting.CreateByUserID; generalSettingBO.UpdateByUserID = generalSetting.UpdateByUserID; if (generalSetting.Company != null) { if (generalSetting.Company.IsDeleted.HasValue == false || (generalSetting.Company.IsDeleted.HasValue == true && generalSetting.Company.IsDeleted.Value == false)) { BO.Company boCompany = new BO.Company(); using (UserRepository cmp = new UserRepository(_context)) { boCompany = cmp.Convert <BO.Company, Company>(generalSetting.Company); generalSettingBO.Company = boCompany; } } } return((T)(object)generalSettingBO); }
public override T Convert <T, U>(U entity) { PreferredAttorneyProvider preferredAttorneyProvider = entity as PreferredAttorneyProvider; if (preferredAttorneyProvider == null) { return(default(T)); } BO.PreferredAttorneyProvider boPreferredAttorneyProvider = new BO.PreferredAttorneyProvider(); boPreferredAttorneyProvider.ID = preferredAttorneyProvider.Id; boPreferredAttorneyProvider.PrefAttorneyProviderId = preferredAttorneyProvider.PrefAttorneyProviderId; boPreferredAttorneyProvider.CompanyId = preferredAttorneyProvider.CompanyId; boPreferredAttorneyProvider.IsCreated = preferredAttorneyProvider.IsCreated; boPreferredAttorneyProvider.IsDeleted = preferredAttorneyProvider.IsDeleted; boPreferredAttorneyProvider.CreateByUserID = preferredAttorneyProvider.CreateByUserID; boPreferredAttorneyProvider.UpdateByUserID = preferredAttorneyProvider.UpdateByUserID; if (preferredAttorneyProvider.Company != null) { BO.Company Company = new BO.Company(); if (preferredAttorneyProvider.Company.IsDeleted.HasValue == false || (preferredAttorneyProvider.Company.IsDeleted.HasValue == true && preferredAttorneyProvider.Company.IsDeleted.Value == false)) { using (CompanyRepository sr = new CompanyRepository(_context)) { Company = sr.Convert <BO.Company, Company>(preferredAttorneyProvider.Company); Company.Locations = null; } } boPreferredAttorneyProvider.Company = Company; } if (preferredAttorneyProvider.Company1 != null) { BO.Company Company = new BO.Company(); if (preferredAttorneyProvider.Company1.IsDeleted.HasValue == false || (preferredAttorneyProvider.Company1.IsDeleted.HasValue == true && preferredAttorneyProvider.Company1.IsDeleted.Value == false)) { using (CompanyRepository sr = new CompanyRepository(_context)) { Company = sr.Convert <BO.Company, Company>(preferredAttorneyProvider.Company1); Company.Locations = null; } } boPreferredAttorneyProvider.PrefAttorneyProvider = Company; } return((T)(object)boPreferredAttorneyProvider); }
public override List <MIDAS.GBX.BusinessObjects.BusinessValidation> Validate <T>(T entity) { BO.Signup signUPBO = (BO.Signup)(object) entity; BO.Company companyBO = signUPBO.company; BO.User userBO = signUPBO.user; var result = companyBO.Validate(companyBO); return(result); }
public override T Convert <T, U>(U entity) { OTPCompanyMapping otpCompanyMapping = entity as OTPCompanyMapping; if (otpCompanyMapping == null) { return(default(T)); } BO.OTPCompanyMapping otpCompanyMappingBO = new BO.OTPCompanyMapping(); otpCompanyMappingBO.ID = otpCompanyMapping.Id; otpCompanyMappingBO.OTP = otpCompanyMapping.OTP; otpCompanyMappingBO.CompanyId = otpCompanyMapping.CompanyId; otpCompanyMappingBO.ValidUntil = otpCompanyMapping.ValidUntil; otpCompanyMappingBO.UsedByCompanyId = otpCompanyMapping.UsedByCompanyId; otpCompanyMappingBO.UsedAtDate = otpCompanyMapping.UsedAtDate; otpCompanyMappingBO.IsCancelled = otpCompanyMapping.IsCancelled; otpCompanyMappingBO.OTPForDate = otpCompanyMapping.OTPForDate; if (otpCompanyMapping.Company != null) { Company company = otpCompanyMapping.Company; BO.Company boCompany = new BO.Company(); boCompany.ID = company.id; boCompany.Name = company.Name; boCompany.TaxID = company.TaxID == null ? null : company.TaxID; boCompany.Status = (BO.GBEnums.AccountStatus)company.Status; boCompany.CompanyType = (BO.GBEnums.CompanyType)company.CompanyType; if (company.SubscriptionPlanType != null) { boCompany.SubsCriptionType = (BO.GBEnums.SubsCriptionType)company.SubscriptionPlanType; } else { boCompany.SubsCriptionType = null; } boCompany.CompanyStatusTypeID = (BO.GBEnums.CompanyStatusType)company.CompanyStatusTypeID; otpCompanyMappingBO.Company = boCompany; } if (otpCompanyMapping.IsDeleted.HasValue) { otpCompanyMappingBO.IsDeleted = otpCompanyMapping.IsDeleted.Value; } if (otpCompanyMapping.UpdateByUserID.HasValue) { otpCompanyMappingBO.UpdateByUserID = otpCompanyMapping.UpdateByUserID.Value; } return((T)(object)otpCompanyMappingBO); }
public override Object Delete <T>(T entity) { BO.Company companyBO = entity as BO.Company; Company companyDB = new Company(); companyDB.id = companyBO.ID; _dbSet.Remove(_context.Companies.Single <Company>(p => p.id == companyBO.ID)); _context.SaveChanges(); var res = (BO.GbObject)(object) entity; return(companyDB); }
public override Object Get(int id) { BO.Company acc_ = Convert <BO.Company, Company>(_context.Companies.Where(p => p.id == id).FirstOrDefault <Company>()); return(acc_); }
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 T Convert <T, U>(U entity) { CompanySpecialtyDetail companyspecialtydetail = entity as CompanySpecialtyDetail; if (companyspecialtydetail == null) { return(default(T)); } BO.CompanySpecialtyDetails companyspecialtyDetailBO = new BO.CompanySpecialtyDetails(); companyspecialtyDetailBO.ID = companyspecialtydetail.id; companyspecialtyDetailBO.SpecialtyId = companyspecialtydetail.SpecialtyId; companyspecialtyDetailBO.CompanyID = companyspecialtydetail.CompanyID; if (companyspecialtydetail.ReevalDays.HasValue) { companyspecialtyDetailBO.ReevalDays = companyspecialtydetail.ReevalDays.Value; } if (companyspecialtydetail.ReevalVisitCount.HasValue) { companyspecialtyDetailBO.ReevalVisitCount = companyspecialtydetail.ReevalVisitCount.Value; } if (companyspecialtydetail.InitialDays.HasValue) { companyspecialtyDetailBO.InitialDays = companyspecialtydetail.InitialDays.Value; } if (companyspecialtydetail.InitialVisitCount.HasValue) { companyspecialtyDetailBO.InitialVisitCount = companyspecialtydetail.InitialVisitCount.Value; } if (companyspecialtydetail.MaxReval.HasValue) { companyspecialtyDetailBO.MaxReval = companyspecialtydetail.MaxReval.Value; } if (companyspecialtydetail.IsInitialEvaluation.HasValue) { companyspecialtyDetailBO.IsInitialEvaluation = companyspecialtydetail.IsInitialEvaluation.Value; } if (companyspecialtydetail.Include1500.HasValue) { companyspecialtyDetailBO.Include1500 = companyspecialtydetail.Include1500.Value; } if (companyspecialtydetail.AssociatedSpecialty.HasValue) { companyspecialtyDetailBO.AssociatedSpecialty = companyspecialtydetail.AssociatedSpecialty.Value; } if (companyspecialtydetail.AllowMultipleVisit.HasValue) { companyspecialtyDetailBO.AllowMultipleVisit = companyspecialtydetail.AllowMultipleVisit.Value; } companyspecialtyDetailBO.InitialCode = companyspecialtydetail.InitialCode; companyspecialtyDetailBO.ReEvalCode = companyspecialtydetail.ReEvalCode; //companyspecialtyDetailBO.MandatoryProcCode = companyspecialtydetail.MandatoryProcCode; if (companyspecialtydetail.IsDeleted.HasValue) { companyspecialtyDetailBO.IsDeleted = companyspecialtydetail.IsDeleted.Value; } if (companyspecialtydetail.UpdateByUserID.HasValue) { companyspecialtyDetailBO.UpdateByUserID = companyspecialtydetail.UpdateByUserID.Value; } if (companyspecialtydetail.Specialty != null) { BO.Specialty boSpecialty = new BO.Specialty(); using (SpecialityRepository sr = new SpecialityRepository(_context)) { boSpecialty = sr.Convert <BO.Specialty, Specialty>(companyspecialtydetail.Specialty); companyspecialtyDetailBO.Specialty = boSpecialty; } } if (companyspecialtydetail.Company != null) { BO.Company boCompany = new BO.Company(); using (CompanyRepository cmp = new CompanyRepository(_context)) { boCompany = cmp.Convert <BO.Company, Company>(companyspecialtydetail.Company); companyspecialtyDetailBO.Company = boCompany; } } return((T)(object)companyspecialtyDetailBO); }
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 T Convert <T, U>(U entity) { if (entity is AttorneyVisit) { AttorneyVisit AttorneyVisitDB = entity as AttorneyVisit; if (AttorneyVisitDB == null) { return(default(T)); } BO.AttorneyVisit AttorneyVisitBO = new BO.AttorneyVisit(); AttorneyVisitBO.ID = AttorneyVisitDB.Id; AttorneyVisitBO.CalendarEventId = AttorneyVisitDB.CalendarEventId; AttorneyVisitBO.CaseId = AttorneyVisitDB.CaseId; AttorneyVisitBO.PatientId = AttorneyVisitDB.PatientId; AttorneyVisitBO.CompanyId = AttorneyVisitDB.CompanyId; AttorneyVisitBO.AttorneyId = AttorneyVisitDB.AttorneyId; AttorneyVisitBO.EventStart = AttorneyVisitDB.EventStart; AttorneyVisitBO.EventEnd = AttorneyVisitDB.EventEnd; AttorneyVisitBO.Subject = AttorneyVisitDB.Subject; AttorneyVisitBO.VisitStatusId = AttorneyVisitDB.VisitStatusId; AttorneyVisitBO.ContactPerson = AttorneyVisitDB.ContactPerson; AttorneyVisitBO.Agenda = AttorneyVisitDB.Agenda; AttorneyVisitBO.IsDeleted = AttorneyVisitDB.IsDeleted; AttorneyVisitBO.CreateByUserID = AttorneyVisitDB.CreateByUserID; AttorneyVisitBO.UpdateByUserID = AttorneyVisitDB.UpdateByUserID; if (AttorneyVisitDB.Patient != null) { BO.Patient PatientBO = new BO.Patient(); using (PatientRepository patientRepo = new PatientRepository(_context)) { PatientBO = patientRepo.Convert <BO.Patient, Patient>(AttorneyVisitDB.Patient); AttorneyVisitBO.Patient = PatientBO; //if (AttorneyVisitDB.Patient.PatientInsuranceInfoes != null && AttorneyVisitDB.Patient.PatientInsuranceInfoes.Count > 0) //{ // List<BO.PatientInsuranceInfo> PatientInsuranceInfoBOList = new List<BO.PatientInsuranceInfo>(); // using (PatientInsuranceInfoRepository patientInsuranceInfoRepo = new PatientInsuranceInfoRepository(_context)) // { // foreach (PatientInsuranceInfo eachPatientInsuranceInfo in AttorneyVisitDB.Patient.PatientInsuranceInfoes) // { // if (eachPatientInsuranceInfo.IsDeleted.HasValue == false || (eachPatientInsuranceInfo.IsDeleted.HasValue == true && eachPatientInsuranceInfo.IsDeleted.Value == false)) // { // PatientInsuranceInfoBOList.Add(patientInsuranceInfoRepo.Convert<BO.PatientInsuranceInfo, PatientInsuranceInfo>(eachPatientInsuranceInfo)); // } // } // AttorneyVisitBO.Patient.PatientInsuranceInfoes = PatientInsuranceInfoBOList; // } //} } } if (AttorneyVisitDB.Case != null) { BO.Case CaseBO = new BO.Case(); using (CaseRepository caseRepo = new CaseRepository(_context)) { CaseBO = caseRepo.Convert <BO.Case, Case>(AttorneyVisitDB.Case); AttorneyVisitBO.Case = CaseBO; if (AttorneyVisitDB.Case.PatientAccidentInfoes != null && AttorneyVisitDB.Case.PatientAccidentInfoes.Count > 0) { List <BO.PatientAccidentInfo> PatientAccidentInfoBOList = new List <BO.PatientAccidentInfo>(); using (PatientAccidentInfoRepository patientAccidentInfoRepo = new PatientAccidentInfoRepository(_context)) { foreach (PatientAccidentInfo eachPatientInsuranceInfo in AttorneyVisitDB.Case.PatientAccidentInfoes) { if (eachPatientInsuranceInfo.IsDeleted.HasValue == false || (eachPatientInsuranceInfo.IsDeleted.HasValue == true && eachPatientInsuranceInfo.IsDeleted.Value == false)) { PatientAccidentInfoBOList.Add(patientAccidentInfoRepo.Convert <BO.PatientAccidentInfo, PatientAccidentInfo>(eachPatientInsuranceInfo)); } } AttorneyVisitBO.Case.PatientAccidentInfoes = PatientAccidentInfoBOList; } } } } if (AttorneyVisitDB.Company != null) { BO.Company boCompany = new BO.Company(); using (CompanyRepository cmp = new CompanyRepository(_context)) { boCompany = cmp.Convert <BO.Company, Company>(AttorneyVisitDB.Company); AttorneyVisitBO.Company = boCompany; } } if (AttorneyVisitDB.CalendarEvent != null) { AttorneyVisitBO.CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { AttorneyVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(AttorneyVisitDB.CalendarEvent); } } return((T)(object)AttorneyVisitBO); } else if (entity is CalendarEvent) { CalendarEvent CalendarEventDB = entity as CalendarEvent; if (CalendarEventDB == null) { return(default(T)); } BO.CalendarEvent CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(CalendarEventDB); } return((T)(object)CalendarEvent); } return(default(T)); }
public T ConvertEOvisit <T, U>(U entity) { if (entity is EOVisit) { EOVisit EOVisit = entity as EOVisit; if (EOVisit == null) { return(default(T)); } BO.EOVisit EOVisitBO = new BO.EOVisit(); EOVisitBO.ID = EOVisit.ID; EOVisitBO.CalendarEventId = EOVisit.CalendarEventId; EOVisitBO.DoctorId = EOVisit.DoctorId; EOVisitBO.PatientId = EOVisit.PatientId; EOVisitBO.VisitCreatedByCompanyId = EOVisit.PatientId; EOVisitBO.InsuranceProviderId = EOVisit.InsuranceProviderId; EOVisitBO.VisitStatusId = EOVisit.VisitStatusId; EOVisitBO.EventStart = EOVisit.EventStart; EOVisitBO.EventEnd = EOVisit.EventEnd; EOVisitBO.Notes = EOVisit.Notes; EOVisitBO.IsDeleted = EOVisit.IsDeleted; EOVisitBO.CreateByUserID = EOVisit.CreateByUserID; EOVisitBO.UpdateByUserID = EOVisit.UpdateByUserID; if (EOVisit.Doctor != null) { BO.Doctor doctorBO = new BO.Doctor(); using (DoctorRepository patientRepo = new DoctorRepository(_context)) { doctorBO = patientRepo.Convert <BO.Doctor, Doctor>(EOVisit.Doctor); EOVisitBO.Doctor = doctorBO; } } if (EOVisit.Patient != null) { BO.Patient PatientBO = new BO.Patient(); using (PatientRepository patientRepo = new PatientRepository(_context)) { PatientBO = patientRepo.Convert <BO.Patient, Patient>(EOVisit.Patient); EOVisitBO.Patient = PatientBO; } } if (EOVisit.Company != null) { BO.Company CompanyBO = new BO.Company(); using (CompanyRepository companyRepo = new CompanyRepository(_context)) { CompanyBO = companyRepo.Convert <BO.Company, Company>(EOVisit.Company); EOVisitBO.Company = CompanyBO; } } if (EOVisit.InsuranceMaster != null) { BO.InsuranceMaster InsuranceMasterBO = new BO.InsuranceMaster(); using (InsuranceMasterRepository InsuranceMasterRepo = new InsuranceMasterRepository(_context)) { InsuranceMasterBO = InsuranceMasterRepo.ObjectConvert <BO.InsuranceMaster, InsuranceMaster>(EOVisit.InsuranceMaster); EOVisitBO.InsuranceMaster = InsuranceMasterBO; } } if (EOVisit.CalendarEvent != null) { EOVisitBO.CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { EOVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(EOVisit.CalendarEvent); } } return((T)(object)EOVisitBO); } return(default(T)); }
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 override object Save <T>(T entity) { BO.CompanySpecialtyDetails companyspecialtyDetailBO = (BO.CompanySpecialtyDetails)(object) entity; CompanySpecialtyDetail companyspeclityDetailDB = new CompanySpecialtyDetail(); if (companyspecialtyDetailBO.Specialty == null) { return(new BO.ErrorObject { ErrorMessage = "Specialty object can't be null", errorObject = "", ErrorLevel = ErrorLevel.Error }); } if (companyspecialtyDetailBO.Company == null) { return(new BO.ErrorObject { ErrorMessage = "Company object can't be null", errorObject = "", ErrorLevel = ErrorLevel.Error }); } BO.Company companyBO = companyspecialtyDetailBO.Company; BO.Specialty specilityBO = companyspecialtyDetailBO.Specialty; #region Specialty companyspeclityDetailDB.id = companyspecialtyDetailBO.ID; companyspeclityDetailDB.SpecialtyId = companyspecialtyDetailBO.SpecialtyId; companyspeclityDetailDB.CompanyID = companyspecialtyDetailBO.CompanyID; companyspeclityDetailDB.ReevalDays = companyspecialtyDetailBO.ReevalDays; companyspeclityDetailDB.ReevalVisitCount = companyspecialtyDetailBO.ReevalVisitCount; companyspeclityDetailDB.InitialDays = companyspecialtyDetailBO.InitialDays; companyspeclityDetailDB.InitialVisitCount = companyspecialtyDetailBO.InitialVisitCount; companyspeclityDetailDB.MaxReval = companyspecialtyDetailBO.MaxReval; companyspeclityDetailDB.IsInitialEvaluation = companyspecialtyDetailBO.IsInitialEvaluation; companyspeclityDetailDB.Include1500 = companyspecialtyDetailBO.Include1500; companyspeclityDetailDB.AssociatedSpecialty = companyspecialtyDetailBO.AssociatedSpecialty; companyspeclityDetailDB.AllowMultipleVisit = companyspecialtyDetailBO.AllowMultipleVisit; companyspeclityDetailDB.InitialCode = companyspecialtyDetailBO.InitialCode; companyspeclityDetailDB.ReEvalCode = companyspecialtyDetailBO.ReEvalCode; //companyspeclityDetailDB.MandatoryProcCode = companyspecialtyDetailBO.MandatoryProcCode; companyspeclityDetailDB.IsDeleted = companyspecialtyDetailBO.IsDeleted; #endregion #region Specialty if (specilityBO.ID > 0) { Specialty speclity = _context.Specialties.Where(p => p.id == specilityBO.ID).FirstOrDefault <Specialty>(); if (speclity != null) { companyspeclityDetailDB.Specialty = speclity; } else { return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Speclity details.", ErrorLevel = ErrorLevel.Error } }; } #endregion #region Company if (companyBO.ID > 0) { Company company = _context.Companies.Where(p => p.id == companyBO.ID).FirstOrDefault <Company>(); if (company != null) { companyspeclityDetailDB.Company = company; } else { return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Company details.", ErrorLevel = ErrorLevel.Error } }; } #endregion if (companyspeclityDetailDB.id > 0) { //Find Specialty By ID CompanySpecialtyDetail companyspecialtydetail = _context.CompanySpecialtyDetails.Where(p => p.id == companyspeclityDetailDB.id).FirstOrDefault <CompanySpecialtyDetail>(); if (companyspecialtydetail != null) { #region Specialty companyspecialtydetail.SpecialtyId = companyspecialtyDetailBO.Specialty.ID != null ? companyspecialtyDetailBO.Specialty.ID : companyspecialtydetail.Specialty.id; companyspecialtydetail.CompanyID = companyspecialtyDetailBO.CompanyID != null ? companyspecialtyDetailBO.CompanyID : companyspecialtydetail.CompanyID; companyspecialtydetail.ReevalDays = companyspecialtyDetailBO.ReevalDays != null ? companyspecialtyDetailBO.ReevalDays : companyspecialtydetail.ReevalDays; companyspecialtydetail.ReevalVisitCount = companyspecialtyDetailBO.ReevalVisitCount != null ? companyspecialtyDetailBO.ReevalVisitCount : companyspecialtydetail.ReevalVisitCount; companyspecialtydetail.InitialDays = companyspecialtyDetailBO.InitialDays != null ? companyspecialtyDetailBO.InitialDays : companyspecialtydetail.InitialDays; companyspecialtydetail.InitialVisitCount = companyspecialtyDetailBO.InitialVisitCount != null ? companyspecialtyDetailBO.InitialVisitCount : companyspecialtydetail.InitialVisitCount; companyspecialtydetail.MaxReval = companyspecialtyDetailBO.MaxReval != null ? companyspecialtyDetailBO.MaxReval : companyspecialtydetail.MaxReval; companyspecialtydetail.IsInitialEvaluation = companyspecialtyDetailBO.IsInitialEvaluation != null ? companyspecialtyDetailBO.IsInitialEvaluation : companyspecialtydetail.IsInitialEvaluation; companyspecialtydetail.Include1500 = companyspecialtyDetailBO.Include1500 != null ? companyspecialtyDetailBO.Include1500 : companyspecialtydetail.Include1500; companyspecialtydetail.AssociatedSpecialty = companyspecialtyDetailBO.AssociatedSpecialty != null ? companyspecialtyDetailBO.AssociatedSpecialty : companyspecialtydetail.AssociatedSpecialty; companyspecialtydetail.AllowMultipleVisit = companyspecialtyDetailBO.AllowMultipleVisit != null ? companyspecialtyDetailBO.AllowMultipleVisit : companyspecialtydetail.AllowMultipleVisit; companyspecialtydetail.InitialCode = companyspecialtyDetailBO.InitialCode != null ? companyspecialtyDetailBO.InitialCode : companyspecialtydetail.InitialCode; companyspecialtydetail.ReEvalCode = companyspecialtyDetailBO.ReEvalCode != null ? companyspecialtyDetailBO.ReEvalCode : companyspecialtydetail.ReEvalCode; //companyspecialtydetail.MandatoryProcCode = companyspecialtyDetailBO.MandatoryProcCode != null ? companyspecialtyDetailBO.MandatoryProcCode : companyspecialtydetail.MandatoryProcCode; companyspecialtydetail.IsDeleted = companyspecialtyDetailBO.IsDeleted != null ? companyspecialtyDetailBO.IsDeleted : companyspecialtydetail.IsDeleted; companyspecialtydetail.UpdateDate = DateTime.UtcNow; companyspecialtydetail.UpdateByUserID = companyspecialtyDetailBO.UpdateByUserID; #endregion _context.Entry(companyspecialtydetail).State = System.Data.Entity.EntityState.Modified; } } else { companyspeclityDetailDB.CreateDate = DateTime.UtcNow; companyspeclityDetailDB.CreateByUserID = companyspecialtyDetailBO.CreateByUserID; _dbSet.Add(companyspeclityDetailDB); } _context.SaveChanges(); var res = Convert <BO.CompanySpecialtyDetails, CompanySpecialtyDetail>(companyspeclityDetailDB); return((object)res); }
public T ConvertIMEvisit <T, U>(U entity) { if (entity is IMEVisit) { IMEVisit IMEVisit = entity as IMEVisit; if (IMEVisit == null) { return(default(T)); } BO.IMEVisit IMEVisitBO = new BO.IMEVisit(); IMEVisitBO.ID = IMEVisit.ID; IMEVisitBO.CalendarEventId = IMEVisit.CalendarEventId; IMEVisitBO.CaseId = IMEVisit.CaseId; IMEVisitBO.PatientId = IMEVisit.PatientId; IMEVisitBO.EventStart = IMEVisit.EventStart; IMEVisitBO.EventEnd = IMEVisit.EventEnd; IMEVisitBO.Notes = IMEVisit.Notes; IMEVisitBO.VisitStatusId = IMEVisit.VisitStatusId; IMEVisitBO.TransportProviderId = IMEVisit.TransportProviderId; IMEVisitBO.DoctorName = IMEVisit.DoctorName; IMEVisitBO.VisitCreatedByCompanyId = IMEVisit.VisitCreatedByCompanyId; IMEVisitBO.IsDeleted = IMEVisit.IsDeleted; IMEVisitBO.CreateByUserID = IMEVisit.CreateByUserID; IMEVisitBO.UpdateByUserID = IMEVisit.UpdateByUserID; if (IMEVisit.Patient != null) { BO.Patient PatientBO = new BO.Patient(); using (PatientRepository patientRepo = new PatientRepository(_context)) { PatientBO = patientRepo.Convert <BO.Patient, Patient>(IMEVisit.Patient); IMEVisitBO.Patient = PatientBO; } } if (IMEVisit.TransportProviderId != null) { BO.Company CompanyBO = new BO.Company(); using (PatientRepository patientRepo = new PatientRepository(_context)) { CompanyBO = patientRepo.Convert <BO.Company, Company>(IMEVisit.Company); IMEVisitBO.Company = CompanyBO; } } if (IMEVisit.CalendarEvent != null) { IMEVisitBO.CalendarEvent = new BO.CalendarEvent(); using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context)) { IMEVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(IMEVisit.CalendarEvent); } } return((T)(object)IMEVisitBO); } return(default(T)); }
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 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 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 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 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 Convert <T, U>(U entity) { if (entity.GetType().Name != "User") { UserCompany usercompany = entity as UserCompany; if (usercompany == null) { return(default(T)); } BO.UserCompany usercompanyBO = new BO.UserCompany(); usercompanyBO.ID = usercompany.id; usercompanyBO.UserId = usercompany.UserID; usercompanyBO.CompanyId = usercompany.CompanyID; usercompanyBO.UserStatusID = (BO.GBEnums.UserStatu)usercompany.UserStatusID; usercompanyBO.IsAccepted = usercompany.IsAccepted; if (usercompany.IsDeleted.HasValue) { usercompanyBO.IsDeleted = usercompany.IsDeleted.Value; } if (usercompany.UpdateByUserID.HasValue) { usercompanyBO.UpdateByUserID = usercompany.UpdateByUserID.Value; } if (usercompany.User != null && (usercompany.User.IsDeleted.HasValue == false || (usercompany.User.IsDeleted.HasValue == true && usercompany.User.IsDeleted.Value == false))) { using (UserRepository sr = new UserRepository(_context)) { BO.User boUser = sr.Convert <BO.User, User>(usercompany.User); usercompanyBO.User = boUser; } } if (usercompany.Company != null && (usercompany.Company.IsDeleted.HasValue == false || (usercompany.Company.IsDeleted.HasValue == true && usercompany.Company.IsDeleted.Value == false))) { using (CompanyRepository sr = new CompanyRepository(_context)) { BO.Company boCompany = sr.Convert <BO.Company, Company>(usercompany.Company); usercompanyBO.Company = boCompany; } } return((T)(object)usercompanyBO); } else { User userDB = entity as User; BO.User boUser = new BO.User(); if (userDB.IsDeleted.HasValue == false || (userDB.IsDeleted.HasValue == true && userDB.IsDeleted.Value == false)) { using (UserRepository sr = new UserRepository(_context)) { boUser = sr.Convert <BO.User, User>(userDB); } } if (boUser.UserCompanies == null && userDB.UserCompanies != null) { boUser.UserCompanies = new List <BO.UserCompany>(); foreach (var eachUserCompany in userDB.UserCompanies) { if (eachUserCompany.IsDeleted.HasValue == false || (eachUserCompany.IsDeleted.HasValue == true && eachUserCompany.IsDeleted.Value == false)) { BO.UserCompany usercompanyBO = new BO.UserCompany(); usercompanyBO.ID = eachUserCompany.id; usercompanyBO.UserId = eachUserCompany.UserID; usercompanyBO.CompanyId = eachUserCompany.CompanyID; usercompanyBO.IsDeleted = eachUserCompany.IsDeleted; usercompanyBO.CreateByUserID = eachUserCompany.CreateByUserID; usercompanyBO.UpdateByUserID = eachUserCompany.UpdateByUserID; usercompanyBO.IsAccepted = true; boUser.UserCompanies.Add(usercompanyBO); } } } return((T)(object)boUser); } }