public OperationResult Delete(int id) { OperationResult operationResult = new OperationResult(); try { Attachment attachment = GetAttachment(id); if (attachment != null) { AttachmentContext db = new AttachmentContext(); db.Entry(attachment).State = EntityState.Deleted; db.SaveChanges(); operationResult.Success = true; operationResult.Message = "Attachment Deleted Successfully"; } else { operationResult.Success = false; operationResult.Message = "Attachment not found"; } } catch (Exception ex) { operationResult.Success = false; operationResult.Message = "An Error Ocured During Deleting the Attachment"; } return(operationResult); }
public async Task <Domain.DomainModels.AttachmentAggregate.Attachment> GetAsync(int attachmentId) { var attachment = await _context.Attachments.FindAsync(attachmentId); if (attachment != null) { await _context.Entry(attachment) .Collection(i => i.Vifs).LoadAsync(); await _context.Entry(attachment) .Collection(i => i.Interfaces).LoadAsync(); await _context.Entry(attachment) .Reference(i => i.Uni).LoadAsync(); } return(attachment); }
public ActionResult Edit([Bind(Include = "Id,Title,AUrl,Status")] Attachment attachment) { if (ModelState.IsValid) { db.Entry(attachment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(attachment)); }
public async Task <Attachment.Domain.DomainModels.AttachmentRoleAggregate.AttachmentRole> GetAsync(int attachmentRoleId) { var attachmentRole = await _context.AttachmentRoles.FindAsync(attachmentRoleId); if (attachmentRole != null) { await _context.Entry(attachmentRole) .Collection(i => i.VifRoles).LoadAsync(); } return(attachmentRole); }