public IActionResult AddOrganization(OrganizationDto model) { var organization = model.MapTo <Organization>(mapper); if (ModelState.IsValid) { unitOfWork.GetRepository <Organization>().InsertAsync(organization); unitOfWork.GetRepository <Organization>().SaveAsync(); return(new ObjectResult("Model added successfully!")); } return(new ObjectResult("Model added unsuccessfully!")); }
public async Task <IActionResult> UpdateOrganization(Guid id, OrganizationDto model) { var organization = model.MapTo <Organization>(mapper); var newOrganization = await unitOfWork.GetRepository <Organization>().GetByIdAsync(id); newOrganization.Name = organization.Name; newOrganization.Post = organization.Post; if (ModelState.IsValid && id == model.Id) { unitOfWork.GetRepository <Organization>().Update(newOrganization); unitOfWork.GetRepository <Organization>().SaveAsync(); return(new ObjectResult("Model updated successfully!")); } return(new ObjectResult("Model updated unsuccessfully!")); }