public ActionResult DeleteConfirmed(int id) { OrderTrack orderTrack = db.OrderTracks.Find(id); db.OrderTracks.Remove(orderTrack); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TID,OrderId,captured,status")] OrderTrack orderTrack) { if (ModelState.IsValid) { db.Entry(orderTrack).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrderId = new SelectList(db.Orders, "OrderId", "OrderNumber", orderTrack.OrderId); return(View(orderTrack)); }
// GET: OrderTracks/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderTrack orderTrack = db.OrderTracks.Find(id); if (orderTrack == null) { return(HttpNotFound()); } return(View(orderTrack)); }
// GET: OrderTracks/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderTrack orderTrack = db.OrderTracks.Find(id); if (orderTrack == null) { return(HttpNotFound()); } ViewBag.OrderId = new SelectList(db.Orders, "OrderId", "OrderNumber", orderTrack.OrderId); return(View(orderTrack)); }
public IActionResult CompleteOrder(long id) { //Check User Permission For this Page if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.ServicesReport, EN_Permissions.CompleteOrder)) { return(Redirect("/Home")); } string status = "success"; string errorMessage = ""; try { var order = _uow.OrderRepository.GetById(id); if (order == null || order.OrderTrackActionId >= (int)EN_OrderActions.completed) { status = "error"; errorMessage = "Order not found"; } else { order.ModifiedBy = AppSession.CurrentUser.Id; order.ModificationDate = DateTime.Now; order.OrderTrackActionId = (int)EN_OrderActions.completed; order.DeliverDate = DateTime.Now; _uow.OrderRepository.Update(order); //add order track action OrderTrack action = new OrderTrack(); action.CreatedBy = AppSession.CurrentUser.Id; action.CreationDate = DateTime.Now; action.OrderId = order.Id; action.OrderTrackActionId = (int)EN_OrderActions.completed; _uow.OrderTrackRepository.Add(action); _uow.Save(); } } catch (Exception ex) { status = "error"; errorMessage = "Complete Order Error message"; } return(Json(new { status = status, ErrorMessage = errorMessage })); }
/// <summary> /// Add track to User's Cart /// </summary> /// <param name="userId">User's ID</param> /// <param name="trackId">Added Track ID</param> public void AddTrack(int userId, int trackId) { this.CheckInputId(userId, trackId, "Track"); using (var orderTrackRepository = Factory.GetOrderTrackRepository()) { var orderTrack = new OrderTrack() { UserId = userId, TrackId = trackId }; try { orderTrackRepository.AddOrUpdate(orderTrack); orderTrackRepository.SaveChanges(); } catch (SqlException ex) { throw new CartServiceException(this.CheckSqlExceptions(ex)); } } }
public TrackResult Winit_Track(CarrierAPI api, string trackingNum) { TrackResult result = new TrackResult(); if (string.IsNullOrEmpty(trackingNum)) { return(result); } Winit_API winit = new Winit_API(); OrderTrack track = winit.GetOrderTrack(trackingNum); if (winit.ResultError != null) { throw new Exception(winit.ResultError.msg); } if (track != null) { var Winit_EventList = track.trace.ToList(); if (Winit_EventList.Any(e => e.eventCode == "DIC")) { result.PickupDate = Winit_EventList.FirstOrDefault(e => e.eventCode == "DIC")?.date; result.DeliveryStatus = (int)DeliveryStatusType.Intransit; } result.DeliveryNote = Winit_EventList.OrderBy(e => e.date).Select(e => e.date + " " + e.eventDescription).Last(); if (Winit_EventList.Any(e => e.eventCode == "DLC")) { result.DeliveryDate = Winit_EventList.FirstOrDefault(e => e.eventCode == "DLC")?.date; result.DeliveryStatus = (int)DeliveryStatusType.Delivered; } } return(result); }
/// <summary> /// Add track list to User's Cart /// </summary> /// <param name="userId">User's ID</param> /// <param name="trackIds">Added Tracks IDs</param> public void AddTrack(int userId, IEnumerable <int> trackIds) { this.CheckInputIds(userId, trackIds, "Track"); using (var orderTrackRepository = Factory.GetOrderTrackRepository()) { try { foreach (var trackId in trackIds) { var orderTrack = new OrderTrack() { UserId = userId, TrackId = trackId }; orderTrackRepository.AddOrUpdate(orderTrack); } orderTrackRepository.SaveChanges(); } catch (SqlException ex) { throw new CartServiceException(this.CheckSqlExceptions(ex)); } } }
public IActionResult SaveAssignResponsible(long orderId, long responsibleUserId) { string status = "success"; if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.ServicesReport, EN_Permissions.Edit)) { return(Redirect("/Home")); } var order = _uow.OrderRepository.Get(ent => ent.Id == orderId); var technical = _uow.UsersRepository.Get(ent => ent.Id == responsibleUserId); if (order == null) { status = "error"; return(Json(new { status = status, ErrorMessage = "Order Not Found" })); } else if (technical == null) { status = "error"; return(Json(new { status = status, ErrorMessage = "Supplier Not Found" })); } else if (order.ResponsibleUserId != null && order.ResponsibleUserId != 0) { status = "error"; return(Json(new { status = status, ErrorMessage = "Order Already has Responsible User !" })); } else { //update order responsible order.ResponsibleUserId = responsibleUserId; order.ModificationDate = DateTime.Now; order.ModifiedBy = AppSession.CurrentUser.Id; order.OrderTrackActionId = (int)EN_OrderActions.accpted_by_user; _uow.OrderRepository.Update(order); //add order track action to order OrderTrack action = new OrderTrack(); action.CreationDate = DateTime.Now; action.OrderTrackActionId = (int)EN_OrderActions.accpted_by_user; action.OrderId = orderId; _uow.OrderTrackRepository.Add(action); //send notification to customer that his order accepted by technical var customername = _uow.CustomerRepository.Get(ent => ent.Id == order.CustomerId).ArabicName; var technicalname = _uow.UsersRepository.Get(ent => ent.Id == responsibleUserId).ArabicName; Notification notification = new Notification(); notification.Text = "Order With Code: " + order.Code + " Accepted by Technical: " + technicalname; notification.ToUSer = order.CustomerId; notification.URl = "/Order/OrderTrack" + orderId; notification.TypeOfUser = (int)EN_TypeUser.Customer; _uow.NotificationRepository.Add(notification); //send notification with order assigned by admin to supplier Notification techNotification = new Notification(); techNotification.Text = "Order With Code: " + order.Code + " For Customer " + customername + " Added to you By Admin "; techNotification.TypeOfUser = (int)EN_TypeUser.Technical; notification.ToUSer = responsibleUserId; _uow.NotificationRepository.Add(techNotification); _uow.Save(); return(Json(new { status = status })); } }