private void EditCompany(Company company) { //TODO: Check porqué esta dando problemas company.CreatetedAt = DateTime.Now; company.UpdatedAt = DateTime.Now; _companiesRepository.EditCompany(company); }
public async Task <ActionResult <UserModel> > Patch(UserModel model) { UserModel result; try { if (model.City != null) { int id = model.UserId; Student student = await _studentsRepository.GetStudentByIdAsync(id); student.Username = model.Username; student.Password = model.Password; student.City = _mapper.Map <City>(model.City); student.Technology = _mapper.Map <Technology>(model.Technology); result = _mapper.Map <UserModel>(await _studentsRepository.EditStudent(student)); } else { int id = model.UserId; Company company = await _companyRepository.GetCompanyByIdAsync(id); company.Username = model.Username; company.Password = model.Password; company.CompanyDescription = model.CompanyDescription; result = _mapper.Map <UserModel>(await _companyRepository.EditCompany(company)); } if (result == null) { return(BadRequest("Edit mode failed")); } return(result); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Database failure")); } }
public async Task <IActionResult> Edit(int id, AddEditCompanyViewModel model) { await _companiesRep.EditCompany(model, id); return(RedirectToAction("Index")); }