コード例 #1
0
        public ActionResult UpdateInstroduction(InstroductionRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var result = _instroductionService.UpdateInstroduction(request);

            if (!result)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }

            return(RedirectToAction("Index", "Instroduction"));
        }
コード例 #2
0
        public bool CreateInstroduction(InstroductionRequest request)
        {
            if (request == null)
            {
                return(false);
            }

            var newItem = new Instroductions
            {
                Name        = request.Name,
                Description = request.Description,
                CreatedBy   = 1,
                CreatedDate = DateTime.Now
            };

            _instroductionRepository.Add(newItem);

            return(_unitOfWork.Commit());
        }
コード例 #3
0
        public bool UpdateInstroduction(InstroductionRequest request)
        {
            if (!request.Id.HasValue)
            {
                return(false);
            }

            var update = _instroductionRepository.GetById(request.Id.Value);

            if (update == null)
            {
                return(false);
            }

            update.Name         = request.Name;
            update.Description  = request.Description;
            update.ModifiedBy   = 1;
            update.ModifiedDate = DateTime.Now;

            _instroductionRepository.Update(update);

            return(_unitOfWork.Commit());
        }
コード例 #4
0
        public ActionResult Create()
        {
            var instroduction = new InstroductionRequest();

            return(View("Create", instroduction));
        }
コード例 #5
0
ファイル: MappingExtensions.cs プロジェクト: hoangbau/TSI.WEB
 public static Instroductions ConvertRequestToModel(this InstroductionRequest instroduction)
 {
     return(Mapper.Map <InstroductionRequest, Instroductions>(instroduction));
 }