Exemplo n.º 1
0
        //
        // GET: /Todo/CategoryAddEdit/
        public ActionResult CategoryAdd()
        {
            CategoryModel dummy = new CategoryModel();
            dummy.IconModel = new IconSelectModel()
            {
                //default
                SelectedId = 1,
                Icons = WcfApi.Instance.GetAllIcons()
            };

            return View("CategoryAddEdit", dummy);
        }
Exemplo n.º 2
0
        public ActionResult CategoryAdd(CategoryModel catModel)
        {
            if (ModelState.IsValid)
            {
                long userId = WcfApi.Instance.GetUserId(User.Identity.Name);
                catModel.UserId = userId;

                Category cat = catModel.GetCategoryObject();
                if (cat.IconId == 0)
                    cat.IconId = 1;
                WcfApi.Instance.AddCategory(cat);
                return RedirectToAction("Index");
            }

            catModel.IconModel = new IconSelectModel()
            {
                //default
                SelectedId = 1,
                Icons = WcfApi.Instance.GetAllIcons()
            };

            return View("CategoryAddEdit", catModel);
        }
Exemplo n.º 3
0
        // Get: /Todo/CategoryEdit/id
        public ActionResult CategoryAddEdit(long id)
        {
            Category cat = WcfApi.Instance.GetCategory(id);

            CategoryModel model = new CategoryModel()
            {
                Id = cat.Id,
                Order = cat.Order,
                TaskNum = cat.TaskNum,
                Title = cat.Title,
                UserId = cat.UserId,
                IconId = cat.IconId,
            };

            model.IconModel = new IconSelectModel() {
                SelectedId = cat.IconId,
                Icons = WcfApi.Instance.GetAllIcons()
            };

            return View(model);
        }