public IActionResult AddBuilding(TypeOfRoomDto model) { var type = model.MapTo <Type_of_room>(mapper); if (ModelState.IsValid) { unitOfWork.GetRepository <Type_of_room>().InsertAsync(type); unitOfWork.SaveAsync(); return(new ObjectResult("Model added successfully!")); } return(new ObjectResult("Model added unsuccessfully!")); }
public async Task <IActionResult> UpdateBuilding(Guid id, TypeOfRoomDto model) { var type = model.MapTo <Type_of_room>(mapper); var newType = await unitOfWork.GetRepository <Type_of_room>().GetByIdAsync(id); newType.Name = type.Name; if (ModelState.IsValid && id == model.Id) { unitOfWork.GetRepository <Type_of_room>().Update(newType); unitOfWork.GetRepository <Type_of_room>().SaveAsync(); return(new ObjectResult("Model updated successfully!")); } return(new ObjectResult("Model updated unsuccessfully!")); }