示例#1
0
        /// <summary>
        /// Save the sub product
        /// </summary>
        /// <param name="model">The SubProduct model</param>
        public ActionResult SubProductSave(MODEL.SubProduct model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //Get user id
                    int?userId = Session.GetUserId();

                    SubProductService subProductService = new SubProductService();
                    //SubProductVO subProductVO = new SubProductVO(model, userId);

                    SubProductVO subProductVO = model.Transpose(userId);

                    subProductService.SaveSubProduct(subProductVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.SUBPRODUCT));
                }
            }
            catch (ApplicationException e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
示例#2
0
 /// <summary>
 /// Create New SubProduct
 /// </summary>
 /// <param name="productId">The product id</param>
 /// <param name="productName">The product name</param>
 /// <returns>The subProductDetails view</returns>
 public ActionResult SubProductCreate(int productId, string productName)
 {
     try
     {
         MODEL.SubProduct subProduct = new MODEL.SubProduct();
         subProduct.ProductName = productName;
         return(PartialView("SubProductDetails", subProduct));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeAndErrorResult(500, e.Message));
     }
 }
示例#3
0
        /// <summary>
        /// Edit subproduct details
        /// </summary>
        /// <param name="id">SubProduct Id</param>
        /// <returns>The SubProduct Details view</returns>
        public ActionResult SubProductEdit(int id)
        {
            MODEL.SubProduct subProduct = null;
            try
            {
                SubProductService subProductService = new SubProductService();

                //Get sub product details
                SubProductVO subProductVO = subProductService.GetSubProductById(id);
                if (subProductVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.SUBPRODUCT));
                }
                else
                {
                    subProduct = new MODEL.SubProduct(subProductVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("SubProductDetails", subProduct));
        }