コード例 #1
0
        public ActionResult Create(CategoryInputModel categoryInputModel)
        {
            var category = Mapper.Map<CategoryInputModel, Category>(categoryInputModel);

            category.Created = System.DateTime.Now;
            _repository.Create(category);

            return RedirectToAction("Index");
        }
コード例 #2
0
        public ActionResult Edit(CategoryInputModel model, int id)
        {
            if (ModelState.IsValid)
            {
                var category = _repository.GetById<Category>(id);
                var tmpDate = category.Created;
                category = Mapper.Map<CategoryInputModel, Category>(model);
                category.Created = tmpDate;

                _repository.Update(category);

                Success("The model was updated!");
                return RedirectToAction("index");
            }
            return View("Create", model);
        }