public async Task<ActionResult> CreateAsync(DocumentToProjectLink item)
 {
     try
     {
         _dbContext.DocumentToProjectLinks.Add(item);
         await _dbContext.SaveChangesAsync();
         return ActionResult.Success(item);
     }
     catch(Exception ex)
     {
         return ActionResult.Failed(ex);
     }
 }
Ejemplo n.º 2
0
 public async Task<ActionResult> ProcessDocumentsAsync(ProjectWorkflow prjWorkflow, DocumentToProjectLink link2doc, string comment, AppUser currentUser)
 {
     try
     {
         var dbDoc = await _dbContext.ProjectDocuments.FirstOrDefaultAsync(pd => pd.ProjectId == prjWorkflow.Id && pd.Link2StateId == link2doc.Id);
         if (dbDoc == null)
         {
             dbDoc = new ProjectDocument
             {
                 Body = System.Text.Encoding.UTF8.GetBytes(link2doc.DocName),
                 CreatedBy = currentUser,
                 CreatedOn = DateTime.UtcNow,
                 Link2StateId = link2doc.Id,
                 ProjectId = prjWorkflow.Id,
                 StateId = link2doc.StateId,
                 Comment = comment
             };
             _dbContext.ProjectDocuments.Add(dbDoc);
         }
         else
         {
             dbDoc.Body = System.Text.Encoding.UTF8.GetBytes(link2doc.DocName);
             dbDoc.CreatedBy = currentUser;
             dbDoc.CreatedOn = DateTime.UtcNow;
             dbDoc.Link2StateId = link2doc.Id;
             dbDoc.ProjectId = prjWorkflow.Id;
             dbDoc.StateId = link2doc.StateId;
             dbDoc.Comment = comment;
         }
         await _dbContext.SaveChangesAsync();
         return ActionResult.Success(dbDoc);
     }
     catch(Exception ex)
     {
         return ActionResult.Failed(ex);
     }
 }
 public async Task<ActionResult> ModifyAsync(DocumentToProjectLink item)
 {
     try
     {
         var dbItem = await Query().SingleOrDefaultAsync(d => d.Id == item.Id);
         if (item != null)
         {
             dbItem.ActionType = item.ActionType;
             dbItem.DocName = item.DocName;
             dbItem.DocType = item.DocType;
             dbItem.StateId = item.StateId;
             dbItem.DocumentTemplateId = item.DocumentTemplateId;
             await _dbContext.SaveChangesAsync();
         }
         return ActionResult.Success(item);
     }
     catch (Exception ex)
     {
         return ActionResult.Failed(ex);
     }
 }