public ActionResult EditItem(Item item)
        {
            item.ItemId = updateItemId;
            IEcommerceManagerFacade employeeFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager);

            IItemDTO itemDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item);

            itemDTO.ItemId        = item.ItemId;
            itemDTO.ItemName      = item.ItemName;
            itemDTO.SubCategotyId = item.SubCategotyId;

            OperationResult <bool> result = employeeFacade.EditItem(itemDTO);
            JsonResult             retVal;

            if (result.IsValid())
            {
                retVal = new JsonResult()
                {
                    Data = "Sucessfully Updated",
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
            else
            {
                retVal = new JsonResult()
                {
                    Data = "Not Updated",
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
            return(retVal);
        }
Esempio n. 2
0
        private static void editItem()
        {
            IItemDTO itemDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item, null);

            itemDTO.ItemName      = "item";
            itemDTO.ItemId        = 1;
            itemDTO.SubCategotyId = 2;

            IEcommerceManagerFacade itemManagerFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager, null);
            OperationResult <bool>  operationResult   = itemManagerFacade.EditItem(itemDTO);

            if (operationResult.IsValid())
            {
                System.Console.WriteLine("Updated");
            }
            else if (operationResult.HasValidationFailed() && operationResult.ValidationResult != null)
            {
                foreach (EmployeePortalValidationFailure error in operationResult.ValidationResult.Errors)
                {
                    System.Console.WriteLine(error.PropertyName + "  " + error.ErrorMessage);
                }
            }
            else if (operationResult.Message != String.Empty && operationResult.StackTrace != String.Empty)
            {
                System.Console.WriteLine(operationResult.Message + "  " + operationResult.StackTrace);
            }
        }