public static void SaveOrder(OrderHeader orderHeader) { var db = new IstokDoorsDBContext(); var myOrderHeader = new OrderHeader(); myOrderHeader.OrderId = orderHeader.OrderId; myOrderHeader.CustomerId = orderHeader.CustomerId; myOrderHeader.PaymentTermId = orderHeader.PaymentTermId; myOrderHeader.DateOfCreation = orderHeader.DateOfCreation; myOrderHeader.Memo = orderHeader.Memo; myOrderHeader.OrderStatusId = 0; db.OrderHeaders.Add(myOrderHeader); var myOrderSchedule = new OrderFulfillmentSchedule(); myOrderSchedule.OrderId = orderHeader.OrderId; myOrderSchedule.PlannedDateOfManufactoring = orderHeader.OrderFulfillmentSchedule.PlannedDateOfManufactoring; myOrderSchedule.PlannedDateOfShipping = orderHeader.OrderFulfillmentSchedule.PlannedDateOfShipping; db.OrderFulfillmentSchedules.Add(myOrderSchedule); db.SaveChanges(); var lastOrderId = db.OrderHeaders.OrderByDescending(o => o.OrderId).FirstOrDefault(); LastOrderId.OrderId = lastOrderId.OrderId; }
public async Task<ActionResult> AddInfoToOrder(OrderHeader orderheader) { if (String.IsNullOrEmpty(orderheader.PaymentReferece)) { ModelState.AddModelError("PaymentReferece", "The Payment Reference is required"); } if (orderheader.IsShipped == true) { orderheader.OrderStatusId = 5; } // if (ModelState.IsValid) //{ _db.Entry(orderheader).State = EntityState.Modified; _db.Entry(orderheader.OrderFulfillmentSchedule).State = EntityState.Modified; await _db.SaveChangesAsync(); LastOrderId.OrderId = orderheader.OrderId; return RedirectToAction("Index", "Order", orderheader.OrderId); //} //return RedirectToAction("Index"); }
public async Task<ActionResult> Ship (OrderHeader orderheader) { //_db.Entry(orderheader).State = EntityState.Modified; //_db.Entry(orderheader.OrderFulfillmentSchedule).State = EntityState.Modified; var shippedOrder = await _db.OrderHeaders.FindAsync(orderheader.OrderId); if (orderheader.OrderStatusId == 4) { shippedOrder.OrderStatusId = 5; shippedOrder.IsShipped = true; _db.usp_ShipOrder(orderheader.OrderId); await _db.SaveChangesAsync(); } var responsiblePerson = await _db.Employees.FindAsync(112); if (responsiblePerson != null) { string messageText = " Заказ N" + orderheader.OrderId + " отгружен. Проверте Журнал Учёта Складских Запасов для дополнительной информации"; var twilio = new TwilioRestClient(TwilioSender.AccountSid, TwilioSender.AuthToken); var message = twilio.SendMessage(TwilioSender.PhoneNumber, responsiblePerson.PhoneNumber1, messageText, ""); } return RedirectToAction("Index"); }
public async Task<ActionResult> Create( OrderHeader orderheader) { //try //{ ProjectMethods.SaveOrder(orderheader); return RedirectToAction("Create", "OrderItem"); //} //catch //{ //return View("Index"); //} }