public bool SaveOrderNotes(OrderNotesEntity noteData) { var config = new MapperConfiguration(cfg => cfg.CreateMap <OrderNotesEntity, OrderNotes>()); var mapper = config.CreateMapper(); OrderNotes savedNote = mapper.Map <OrderNotesEntity, OrderNotes>(noteData); using (var scope = new TransactionScope()) { if (noteData.NoteId <= 0) { savedNote.Suffix = "OT"; savedNote.Priority = false; savedNote.ClientViewable = true; savedNote.NoteSource = "I"; savedNote.ItemNo = 1; _unitOfWork.OrderNotesRepository.Insert(savedNote); } else { _unitOfWork.OrderNotesRepository.Update(savedNote); } _unitOfWork.Save(); scope.Complete(); return(true); } }
public OrderDto(Order order) { OrderId = order.OrderId; UserId = order.UserId; StreetAddress = order.StreetAddress; UnitDesignation = order.UnitDesignation; City = order.City; Province = order.Province; PostalCode = order.PostalCode; Country = order.Country; TaxEstimate = order.TaxEstimate; ServiceFee = order.ServiceFee; DriverTip = order.DriverTip; TotalEstimate = order.TotalEstimate; TotalExact = order.TotalExact; CreatedDate = order.CreatedDate; AcceptedById = order.AcceptedById; AcceptedDate = order.AcceptedDate; ApprovedDate = order.ApprovedDate; CompletedDate = order.CompletedDate; foreach (LineItem item in order.LineItems) { LineItems.Add(new LineItemDto(item)); } foreach (OrderNote note in order.OrderNotes) { OrderNotes.Add(new OrderNoteDto(note)); } }
public ActionResult Edit(int id) { var cart = Carts.GetByID(id); EditCart editCart = Mapper.Map <EditCart>(cart); editCart.SendMethodType = cart.SendMethodType; editCart.PaymentMethodType = cart.PaymentMethodType; editCart.Notes = OrderNotes.GetByCartID(id); editCart.OrderItems = CartItems.GetOrderItems(id); return(View("/Areas/Admin/Views/Orders/Edit.cshtml", model: editCart)); }
public IActionResult SaveNotes([FromBody] OrderNotes notes) { Dictionary <string, object> res; try { res = Service.createSuccessRes(); res.Add("Inserted", OrderData.SaveNotes(notes)); return(Ok(res)); } catch (System.Exception ex) { res = Service.createErrorRes(ex.Message); return(BadRequest(res)); } }
private static void SaveNotes(EditCart editcart, int cartID, string userID) { var curList = OrderNotes.GetByCartID(cartID); foreach (var note in editcart.Notes) { if (!curList.Any(item => item.ID == note.ID)) { var orderNote = Mapper.Map <OrderNote>(note); orderNote.UserID = userID; orderNote.CartID = cartID; orderNote.LastUpdate = DateTime.Now; OrderNotes.Insert(orderNote); } } }
public static OrderNotes UpdateOrderNotesSession(string pageToken, OrderNotes model) { if (!string.IsNullOrEmpty(pageToken)) { var dList = HttpContext.Current.Session["OrderNotesSession"] as Dictionary <string, List <OrderNotes> >; if (dList == null) { dList = new Dictionary <string, List <OrderNotes> >(); } if (!dList.ContainsKey(pageToken)) { dList.Add(pageToken, new List <OrderNotes>() { }); } var nList = dList[pageToken]; var addRequired = model.OrderNoteId == 0; if (model.OrderID > 0) { var prevNoteId = model.OrderNoteId; if (model.OrderNoteId > 0) { var item = nList.FirstOrDefault(m => m.OrderNoteId == prevNoteId); if (item == null) { nList.Add(model); } else { var index = nList.IndexOf(item); nList[index].OrderNoteId = model.OrderNoteId; nList[index].Notes = model.Notes; nList[index].CreatedBy = model.CreatedBy; nList[index].DateCreated = model.DateCreated; } } } else { var item = nList.FirstOrDefault(m => m.OrderNoteId == model.OrderNoteId); if (addRequired || item == null) { model.OrderNoteId = !nList.Any() ? -1 : nList.Min(m => m.OrderNoteId) - 1; if (model.OrderNoteId > 0) { model.OrderNoteId = -1; } nList.Add(model); } else { var index = nList.IndexOf(item); nList[index].Notes = model.Notes; nList[index].CreatedBy = model.CreatedBy; nList[index].DateCreated = model.DateCreated; } } HttpContext.Current.Session["OrderNotesSession"] = dList; } return(new OrderNotes() { Notes = model.Notes, OrderNoteId = model.OrderNoteId, OrderID = model.OrderID }); }