コード例 #1
0
        public IActionResult CategoryEdit(int?id)
        {
            var entity = _categoryServices.GetById((int)id);

            var model = new CategoryModel()
            {
                CategoryId = entity.CategoryId,
                Title      = entity.Title
            };

            return(View(model));
        }
コード例 #2
0
        public IActionResult ArticleCategoryEditAdmin(int id)
        {
            var entity = _categoryServices.GetById(id);
            var model  = new CategoryModel()
            {
                CategoryId = entity.CategoryId,
                Tittle     = entity.Tittle,
                Url        = entity.Url,
                Image      = entity.Image
            };

            return(View(model));
        }
コード例 #3
0
        public JsonResult Edit(int id)
        {
            if (id == 0)
            {
                return(Json(0));
            }
            var category = _categoryServices.GetById(id);

            if (category == null)
            {
                return(Json(0));
            }
            else
            {
                return(Json(category));
            }
        }
コード例 #4
0
        // GET: Admin/Categories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Category category = _category.GetById(id);

            if (category == null)
            {
                return(HttpNotFound());
            }
            return(View(category));
        }
コード例 #5
0
        public IActionResult CategoryEdit(CategoryModel model)
        {
            //var entity=_categoryServices.GetById(model.CategoryId);
            var entity = _categoryServices.GetById(model.CategoryId);

            if (entity == null)
            {
                return(NotFound());
            }
            entity.Name = model.Name;
            entity.Url  = model.Url;

            _categoryServices.Update(entity);

            var msg = new AlertMessage()
            {
                Message   = $"{entity.Name} isimli kategori güncellendi",
                AlertType = "primary"
            };

            TempData["message"] = JsonConvert.SerializeObject(msg);

            return(RedirectToAction("CategoryList"));
        }
コード例 #6
0
        public HttpResponseMessage Delete(int id)
        {
            var cate = _categoryServices.GetById(id);

            return(ToJson(_categoryServices.Delete(cate)));
        }
コード例 #7
0
        public ActionResult <CategoryViewModel> Get(Guid key)
        {
            var resultService = _categoryServices.GetById(key);

            return(_mapper.Map <CategoryViewModel>(resultService));
        }