public static void Update(this VacancyModel vacancy, VacancyUpdateModel updateRequest) { UpdateField(vacancy, ((item, value) => item.Title = value), updateRequest.Title); UpdateField(vacancy, ((item, value) => item.Description = value), updateRequest.Description); UpdateField(vacancy, ((item, value) => item.EmploymentType = value.ToEmploymentType()), updateRequest.EmploymentType); UpdateField(vacancy, ((item, value) => item.Salary = value), updateRequest.Salary); UpdateField(vacancy, ((item, value) => item.ContactPerson = value), updateRequest.ContactPerson); UpdateField(vacancy, ((item, value) => item.ContactPhone = value), updateRequest.ContactPhone); }
public static VacancyUpdateModel ToUpdateCommandBy( this VacancyModel origin, VacancyResponse updated) { var updateModel = new VacancyUpdateModel(); updateModel.Title = GenerateUpdate(origin.Title, updated.Title); updateModel.Description = GenerateUpdate(origin.Description, updated.Description); updateModel.Salary = GenerateUpdate(origin.Salary, updated.Salary); updateModel.ContactPerson = GenerateUpdate(origin.ContactPerson, updated.ContactPerson); updateModel.ContactPhone = GenerateUpdate(origin.ContactPhone, updated.ContactPhone); updateModel.EmploymentType = GenerateUpdate( origin.EmploymentType?.ToList()?.ToStringName(), updated.EmploymentType?.ToList()); return(updateModel); }