public async Task<ApiJsonResult> UpdateJobSeekerProfile(EmployerProfileUpdatedCompanyInfoParams param) { try { Guid userId = GetCurrentUserId(); await new AccountManager(userId).UpdateEmployerProfile(param); return new ApiJsonResult { Success = true, Data = null }; } catch (Exception ex) { return ProcessException(ex); } }
public async Task UpdateEmployerProfile(EmployerProfileUpdatedCompanyInfoParams employerProfileUpdatedCompanyInfoParams) { Utils.CheckNullOrEmpty(new List<string> { "UserId", "CompanyName", "CompanyRegistrationNumber", "Address", "WebLink", "ContactName", "PhoneNumber", "NatureOfBusiness" }, employerProfileUpdatedCompanyInfoParams.UserId, employerProfileUpdatedCompanyInfoParams.CompanyName, employerProfileUpdatedCompanyInfoParams.CompanyRegistrationNumber, employerProfileUpdatedCompanyInfoParams.Address, employerProfileUpdatedCompanyInfoParams.WebLink, employerProfileUpdatedCompanyInfoParams.ContactName, employerProfileUpdatedCompanyInfoParams.PhoneNumber, employerProfileUpdatedCompanyInfoParams.NatureOfBusiness); using (AppDbContext context = new AppDbContext()) { User user = await context.Users.FirstOrDefaultAsync(p => p.Id == employerProfileUpdatedCompanyInfoParams.UserId); Employer employer = await context.Employers.FirstOrDefaultAsync(p => p.UserId == employerProfileUpdatedCompanyInfoParams.UserId); if (employer == null || user == null) { throw new UserException(ErrorCode.INVALID_SESSION.ToString()); } employer.CompanyName = employerProfileUpdatedCompanyInfoParams.CompanyName; employer.CompanyRegistrationNumber = employerProfileUpdatedCompanyInfoParams.CompanyRegistrationNumber; employer.Address = employerProfileUpdatedCompanyInfoParams.Address; employer.WebLink = employerProfileUpdatedCompanyInfoParams.WebLink; employer.ContactName = employerProfileUpdatedCompanyInfoParams.ContactName; employer.PhoneNumber = employerProfileUpdatedCompanyInfoParams.PhoneNumber; employer.NatureOfBusiness = employerProfileUpdatedCompanyInfoParams.NatureOfBusiness; await context.SaveChangesAsync(); } }