public async Task <string> Edit([FromBody] StudentEntity student) { try { await _studentsRepository.EditStudent(student); return("S-a modificat cu succes!"); } catch (System.Exception e) { return("Eroare: " + e.Message); } }
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")); } }