public bool AddPhoto(string accessToken, int orderID, PhotoInfo photo, string fileExtension, string uploadedFileClaimToken) { logMethodInvocation(); checkAccessToken(accessToken); try { using (CFIEntities db = new CFIEntities()) { Order order = getOrderByID(orderID, db); // the file name will depend on the po number and how many other photos may have already been added string fileName = getPhotoFileName(order.OrderID, fileExtension); photo.FilePath = fileName; // claim the uploaded file and name it and store it in the proper location byte[] photoBytes = Globals.FileTransferManager.Uploader.ClaimFile(uploadedFileClaimToken); savePhoto(order.OrderID, fileName, photoBytes); POPhoto poPhoto = ConversionUtils.ToPOPhoto(photo, orderID); order.POPhotos.Add(poPhoto); db.SaveChanges(); } return(true); } catch (Exception ex) { logException(ex); return(false); } }
public bool UpdateNoteText(string accessToken, int noteID, string newText) { logMethodInvocation(); checkAccessToken(accessToken); try { using (CFIEntities db = new CFIEntities()) { PONote poNote = getPONoteByID(noteID, db); poNote.NoteText = newText; db.SaveChanges(); } return(true); } catch (Exception ex) { logException(ex); return(false); } }
public bool AddNote(string accessToken, int orderID, NoteInfo note) { logMethodInvocation(); checkAccessToken(accessToken); try { using (CFIEntities db = new CFIEntities()) { Order order = getOrderByID(orderID, db); PONote poNote = ConversionUtils.ToPONote(note, orderID); order.PONotes.Add(poNote); db.SaveChanges(); } return(true); } catch (Exception ex) { logException(ex); return(false); } }
public bool DeleteNote(string accessToken, int noteID) { logMethodInvocation(); checkAccessToken(accessToken); try { using (CFIEntities db = new CFIEntities()) { PONote poNote = getPONoteByID(noteID, db); if (poNote != null) { poNote.Deleted = true; db.SaveChanges(); } } return(true); } catch (Exception ex) { logException(ex); return(false); } }
public bool DeletePhoto(string accessToken, int photoID) { logMethodInvocation(); checkAccessToken(accessToken); try { using (CFIEntities db = new CFIEntities()) { POPhoto poPhoto = getPOPhotoByID(photoID, db); if (poPhoto != null) { poPhoto.Deleted = true; db.SaveChanges(); deletePhoto(poPhoto.Order.OrderID, poPhoto.FilePath); } } return(true); } catch (Exception ex) { logException(ex); return(false); } }