Esempio n. 1
0
        public ActionResult AddFolder(AssetCategoryModel model)
        {
            if (!ModelState.IsValid)
            {
                return Json(new JsonResultError("AssetCategory model is not valid."));
            }

            var currentHotelId = AppService.GetCurrentHotelId();

            var assetCategory = AssetCategory.Create(currentHotelId, model.Name);
            AssetCategoryService.Save(assetCategory);

            return Json(new JsonResultSuccess("Created succesfully.",
                new
                {
                    id = assetCategory.Id,
                    name = assetCategory.Name,
                    created = true
                })
            );
        }
Esempio n. 2
0
        public ActionResult Folder(int id)
        {
            var currentHotelId = AppService.GetCurrentHotelId();
            var categories = AssetCategoryService.FindAllByHotelId(currentHotelId);

            var assetCategory = categories.FirstOrDefault(x => x.Id == id);
            if (assetCategory.IsNull())
            {
                throw new ArgumentNullException("assetCategory", "AssetCategory does not exist.");
            }

            var model = new AssetCategoryModel(assetCategory.Id, categories, assetCategory.Items);

            return View(model);
        }
Esempio n. 3
0
        public ActionResult EditFolder(AssetCategoryModel model)
        {
            if (!ModelState.IsValid)
            {
                return Json(new JsonResultError("AssetCategory model is not valid."));
            }

            var currentOrganizationId = AppService.GetCurrentOrganizationId();

            var assetCategory = AssetCategoryService.FindById(model.Id, currentOrganizationId);
            if(assetCategory.IsNull())
            {
                throw new ArgumentNullException("assetCategory", "AssetCategory is null.");
            }

            assetCategory.Name = model.Name;

            AssetCategoryService.Save(assetCategory);

            return Json(new JsonResultSuccess("Updated succesfully."));
        }