public ActionResult AddItemPrice(ItemPriceObject itemPrice) { var gVal = new GenericValidator(); try { var valStatus = ValidateItemPrice(itemPrice); if (valStatus.Code < 1) { gVal.Code = 0; gVal.Error = valStatus.Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var k = new ItemPriceServices().AddItemPrice(itemPrice); if (k < 1) { gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure; gVal.Code = 0; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = k; gVal.Error = message_Feedback.Insertion_Success; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = -1; gVal.Error = message_Feedback.Process_Failed; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public long AddItemPrice(ItemPriceObject itemPriceAccount) { try { return(_itemPriceRepository.AddItemPrice(itemPriceAccount)); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
private GenericValidator ValidateItemPrice(ItemPriceObject itemPrice) { var gVal = new GenericValidator(); if (itemPrice == null) { gVal.Code = -1; gVal.Error = message_Feedback.Fatal_Error; return(gVal); } if (itemPrice.Price < 1) { gVal.Code = -1; gVal.Error = message_Feedback.Price_In_Stock_Error; return(gVal); } if (itemPrice.MinimumQuantity < 1) { gVal.Code = -1; gVal.Error = message_Feedback.Min_Quantity_Error; return(gVal); } if (itemPrice.StoreItemStockId < 1) { gVal.Code = -1; gVal.Error = message_Feedback.Store_Item_Stock_Selection_Error; return(gVal); } if (itemPrice.UoMId < 1) { gVal.Code = -1; gVal.Error = message_Feedback.UoM_Selection_Error; return(gVal); } gVal.Code = 5; return(gVal); }
public ActionResult EditPrice(ItemPriceObject itemPrice) { var gVal = new GenericValidator(); try { if (itemPrice.ItemPriceId < 1) { gVal.Code = 0; gVal.Error = "Item could not be processed. Please try again."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var valStatus = ValidateItemPrice(itemPrice); if (valStatus.Code < 1) { gVal.Code = 0; gVal.Error = valStatus.Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var k = new ItemPriceServices().UpdateItemPrice(itemPrice); if (k < 1) { gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure; gVal.Code = 0; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = itemPrice.ItemPriceId; gVal.Error = message_Feedback.Update_Success; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = -1; gVal.Error = message_Feedback.Process_Failed; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public int UpdateItemPrice(ItemPriceObject itemPrice) { return(_itemPriceRepository.UpdateItemPrice(itemPrice)); }
public ActionResult EditItemPrice(ItemPriceObject itemPrice) { var gVal = new GenericValidator(); try { if (ModelState.IsValid) { var valStatus = ValidateItemPrice(itemPrice); if (valStatus.Code < 1) { gVal.Code = 0; gVal.Error = valStatus.Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_itemPrice"] == null) { gVal.Code = -1; gVal.Error = message_Feedback.Session_Time_Out; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldItemPrice = Session["_itemPrice"] as ItemPriceObject; if (oldItemPrice == null || oldItemPrice.ItemPriceId < 1) { gVal.Code = -5; gVal.Error = message_Feedback.Session_Time_Out; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldItemPrice.Price = itemPrice.Price; oldItemPrice.StoreItemStockId = itemPrice.StoreItemStockId; oldItemPrice.UoMId = itemPrice.UoMId; oldItemPrice.MinimumQuantity = itemPrice.MinimumQuantity; oldItemPrice.Remark = itemPrice.Remark; var k = new ItemPriceServices().UpdateItemPrice(oldItemPrice); if (k < 1) { gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure; gVal.Code = 0; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = 5; gVal.Error = message_Feedback.Update_Success; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = -5; gVal.Error = message_Feedback.Process_Failed; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = -1; gVal.Error = message_Feedback.Process_Failed; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }