public RequestWithAttachments GetRequestWithAttachments(int id) { if (!authentificated) { throw new Exception(); } Request res = db.Requests.FirstOrDefault(i => i.Id == id); if (res == null || res.login_senderId != LoginOfUser) { throw new Exception(); } RequestWithAttachments result = new RequestWithAttachments(res, db.AttachmentDatas.Where(i => i.RequestId == res.Id).ToList()); return(result); }
public bool AddRequest(RequestWithAttachments requestWithAttachments) { if (requestWithAttachments.Request.login_senderId != LoginOfUser || !authentificated) { throw new Exception(); } db.Requests.Add(requestWithAttachments.Request); db.SaveChanges(); if (requestWithAttachments.attachmentList != null && requestWithAttachments.attachmentList.Count != 0) { for (int x = 0; x < requestWithAttachments.attachmentList.Count; x++) { requestWithAttachments.attachmentList[x].ordinalNumber = x; requestWithAttachments.attachmentList[x].RequestId = requestWithAttachments.Request.Id; db.AttachmentDatas.Add(requestWithAttachments.attachmentList[x]); } } db.SaveChanges(); return(true); }
public bool AddRequest(RequestWithAttachments requestWithAttachments) { return(contract.AddRequest(requestWithAttachments)); }
public bool AddRequest(RequestWithAttachments requestWithAttachments) { return(Channel.AddRequest(requestWithAttachments)); }