public virtual ActionResult CustomerConstraintEditor(string customerId, int activeTab) { CustomerConstraintEditorModel model; if (string.IsNullOrEmpty(customerId)) { model = new CustomerConstraintEditorModel(); } else { //string customerName; var customerConstraints = _service.Value.GetCustomerConstraints(customerId); //TC2: If no constraint defined for passed customer. This haapnned only when when some one deleted customer. if (customerConstraints == null) { throw new ArgumentOutOfRangeException("customerId", string.Format("Customer {0} does not exist. It may have been deleted", customerId)); } model = new CustomerConstraintEditorModel(customerConstraints) { CustomerId = customerId, CustomerName = _service.Value.GetCustomerName(customerId), ActiveTab = activeTab }; } return(PartialView(Views._customerConstraintEditorPartial, model)); }
public virtual ActionResult UpdateCustomerConstraints(string customerId, CustomerConstraintEditorModel constraints, int?activeTab) { //TC3: You will get here if required feild does not passed. if (!ModelState.IsValid) { ModelState.AddModelError("", "Required fields must be passed"); return(RedirectToAction(Actions.Constraint(activeTab))); } //TC4:You will get here if user update min pieces more than max sku pieces. if (constraints.OrigRequiredMinSkuPieces != constraints.RequiredMinSkuPieces || constraints.OrigRequiredMaxSkuPieces != constraints.RequiredMaxSkuPieces) { if ((constraints.RequiredMinSkuPieces > constraints.OrigRequiredMaxSkuPieces && constraints.RequiredMinSkuPieces > constraints.RequiredMaxSkuPieces) || constraints.RequiredMinSkuPieces > constraints.RequiredMaxSkuPieces) { ModelState.AddModelError("", "Max SKU pieces must be greater than or equal to Min SKU pieces."); return(RedirectToAction(Actions.Constraint(activeTab))); } _service.Value.UpdateSkuMinMaxPieces(customerId, constraints.RequiredMinSkuPieces, constraints.RequiredMaxSkuPieces, constraints.OrigRequiredMaxSkuPieces, constraints.OrigRequiredMinSkuPieces); } //TC5: Update Max box weight value only if is different from its old value. if (constraints.OrigMaxBoxWeight != constraints.MaxBoxWeight) { _service.Value.UpdateMaxBoxWeight(customerId, constraints.MaxBoxWeight); } //TC6: Upate MaxSkuWithinBox value only if is different from its old value. if (constraints.OrigMaxSkuWithinBox != constraints.MaxSkuWithinBox) { _service.Value.UpdateMaxSkuInBox(customerId, constraints.MaxSkuWithinBox); } //TC7: Update single style color value only if is different from its old value. if (constraints.OrigIsSingleStyleColor != constraints.IsSingleStyleColor) { _service.Value.UpdateSkuMixing(customerId, constraints.IsSingleStyleColor); } AddStatusMessage(string.Format("Provided setting has been set for the Customer: {0}.", customerId)); return(RedirectToAction(Actions.Constraint(activeTab))); }