예제 #1
0
        public static C.FoodCategory ToContract(this VendorFoodCategory data)
        {
            if (data == null)
                return null;

            var model = new C.FoodCategory()
            {
                FoodCategoryId = data.VendorFoodCategoryId,
                Name = data.Name,
                VendorId = data.OrganizationID,
                CategoryType = (FoodCategoryTypeEnum)Enum.Parse(typeof(FoodCategoryTypeEnum), data.CategoryType),
            };

            return model;
        }
예제 #2
0
        public ActionResult Save(FoodCategory model)
        {
            SaveFoodCategoryResponse resp = _vendorMgr.SaveFoodCategory(new SaveFoodCategoryRequest { Subject = model });

            if (resp.Status == Status.Success)
            {
                var uiresponse = resp.ToUIResult<FoodCategoryListViewModel
                    , FoodCategory>((foodCategory) => GetList(model.VendorId)
                    , (vm) => RenderPartialViewToString("FoodCategoryList", vm));

                return Json(uiresponse);
            }
            else
            {
                var uiresponse = resp.ToUIResult<FoodCategoryEditModel
                    , FoodCategory>((foodCategory) => new FoodCategoryEditModel(foodCategory)
                    , (vm) => {
                        vm.Merge(resp);

                        return RenderPartialViewToString("AddEdit", vm);
                    });
                return Json(uiresponse);
            }
        }