public async Task <bool> UpdateChangeOfficialDocument(ChangeOfficialDocumentModel input) { using var unitOfWork = UnitOfWorkFactory(); _changeOfficialDocument = unitOfWork.Repository <ChangeOfficialDocument>(); _changeOfficialDocumentType = unitOfWork.Repository <ChangeOfficialDocumentType>(); try { if (await _changeOfficialDocument.IsDuplicated(0, input.Name)) { throw new AppException(string.Format(AppMessages.ThisObjectIsExist, "Giấy tờ/biểu mẫu")); } var type = await GetOrThrow(_changeOfficialDocumentType, input.ChangeOfficialDocumentTypeId, string.Format(AppMessages.ThisObjectNotFound, "Loại giấy tờ/biểu mẫu")); // // UPDATE var changeOfficialDocument = await GetOrThrow(_changeOfficialDocument, input.Id, string.Format(AppMessages.ThisObjectNotFound, "Giấy tờ/biểu mẫu")); changeOfficialDocument.Name = input.Name.Trim(); changeOfficialDocument.ChangeOfficialDocumentTypeId = type.Id; await unitOfWork.SaveChangesAsync(); return(true); } catch (Exception e) { _logger.Error(e, e.Message); throw new AppException(e.Message); } }
public async Task <bool> UpdateChangeOfficialDocument([FromBody] ChangeOfficialDocumentModel input) { return(await _settingService.UpdateChangeOfficialDocument(input)); }