/// <summary> /// Handles an action link for Send-To-Shop /// </summary> public ActionResult Action(string actionToPerform, string token) { // TODO: Add Check to ensure user is logged in and they are a Partner Admin SendToShopOrderStatus status = SendToShopOrderStatus.Created; switch (actionToPerform.ToLower()) { case "cancel": status = SendToShopOrderStatus.Cancelled; break; case "hold": status = SendToShopOrderStatus.OnHold; break; case "started": status = SendToShopOrderStatus.InProgress; break; case "ready": status = SendToShopOrderStatus.ReadyForPickup; break; case "complete": status = SendToShopOrderStatus.Completed; break; default: throw new InvalidOperationException("Status not supported"); } using (var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork()) { try { var sendToShopOrderId = Int32.Parse(this.StringCryptoService.Decrypt(token)); // Update Status this.SendToShopService.UpdateStatus(sendToShopOrderId, status); // Commit and Notify unitOfWork.Commit(); // Only Notify if it is not the Complete Status if (status != SendToShopOrderStatus.Completed) { this.SendToShopService.Notify(sendToShopOrderId); } return(Content("Success")); } catch (Exception ex) { this.LogHandledException(ex); return(Content("Failure\n\n" + ex.ToString())); // TODO: Remove the error message after testing is solid } } }
/// <summary> /// Updates the status of a send to shop order /// </summary> public void UpdateStatus(int orderId, SendToShopOrderStatus status) { if (orderId <= 0) { throw new ArgumentOutOfRangeException("orderId"); } var sendToShopOrder = this.Repository.GetSet <SendToShopOrder>() .Where(x => x.SendToShopOrderId == orderId) .Where(x => x.SendToShopOrderStatusId != (int)status) .FirstOrDefault(); if (sendToShopOrder == null) { throw new InvalidOperationException("Could not find send-to-shop order with differing status"); } sendToShopOrder.SendToShopOrderStatusId = (int)status; sendToShopOrder.DateModified = DateTime.Now; }
/// <summary> /// Updates the status of a send to shop order /// </summary> public void UpdateStatus(int orderId, SendToShopOrderStatus status) { if(orderId <= 0) { throw new ArgumentOutOfRangeException("orderId"); } var sendToShopOrder = this.Repository.GetSet<SendToShopOrder>() .Where(x => x.SendToShopOrderId == orderId) .Where(x => x.SendToShopOrderStatusId != (int)status) .FirstOrDefault(); if(sendToShopOrder == null) { throw new InvalidOperationException("Could not find send-to-shop order with differing status"); } sendToShopOrder.SendToShopOrderStatusId = (int)status; sendToShopOrder.DateModified = DateTime.Now; }