protected virtual async Task <int> Create(DocumentsDto input) { var documents = ObjectMapper.Map <Documents>(input); string date = DateTime.Today.ToString("dd-MM-yyyy"); if (AbpSession.TenantId != null) { documents.TenantId = (int?)AbpSession.TenantId; } var docID = await _documentsRepository.InsertAndGetIdAsync(documents); CurrentUnitOfWork.SaveChanges(); //System.Diagnostics.Debug.WriteLine("DocID = " + docID); var documentHandling = new DocumentHandling { DocumentId = docID, Handler = GetCurrentUser().FullName, Content = input.MoreInformation, IsActive = true, Order = 1, PlaceReceive = input.ApprovedBy, TenantId = AbpSession.TenantId, Status = input.Status }; await _documentHandlingRepository.InsertAsync(documentHandling); var typeHandles = _typeHandleRepository.GetAll().FirstOrDefault(x => x.Name == "Tiếp nhận").Id; var documentDetail = new DocumentDetail { DocumentId = docID, DateHandle = DateTime.Now, IsActive = true, TypeHandle = typeHandles, Status = "Văn thư tiếp nhận văn bản" }; await _documentDetailsRepository.InsertAsync(documentDetail); string newFileName = date + "/" + docID + "_" + Path.GetFileNameWithoutExtension(input.Attachment) + Path.GetExtension(input.Attachment); if (File.Exists("wwwroot/" + input.Attachment)) { File.Move("wwwroot/" + input.Attachment, "wwwroot/" + newFileName); } input.Attachment = newFileName; input.Id = docID; await Update(input); await _historyUploadRepository.InsertAsync(new HistoryUpload { File = newFileName, Version = 1, documentID = docID }); return(docID); }
public async Task CreateOrEdit(DocumentsDto input) { if (input.Id == null) { await Create(input); } else { await Update(input); } }
public async Task <int> CreateAndReturnId(DocumentsDto input) { var result = await Create(input); return(result); }
protected virtual async Task Update(DocumentsDto input) { var documents = await _documentsRepository.FirstOrDefaultAsync((int)input.Id); ObjectMapper.Map(input, documents); }