コード例 #1
0
        public IActionResult Edit(LikeAbleAreasViewModel model)
        {
            var like = _mapper.Map <LikeAbleAreasViewModel, LikeableArea>(model);

            if (model == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var updateLike = _aboutRepository.GetLikeAreById(model.Id);

                updateLike.ModifiedBy   = _admin.Name;
                updateLike.ModifiedDate = DateTime.Now;
                if (model.File != null)
                {
                    like.Photo = _fileManager.Upload(model.File);
                }
                else
                {
                    like.Photo = updateLike.Photo;
                }



                _aboutRepository.UpdateLikeArea(updateLike, like);

                return(RedirectToAction("index"));
            }
            return(View(model));
        }
コード例 #2
0
        public IActionResult Create(LikeAbleAreasViewModel model)
        {
            ViewBag.About = _aboutRepository.GetAboutFull();

            if (model == null)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                var like = _mapper.Map <LikeAbleAreasViewModel, LikeableArea>(model);
                like.AddedBy   = _admin.Name;
                like.AddedDate = DateTime.Now;
                if (model.File != null)
                {
                    like.Photo = _fileManager.Upload(model.File);
                }
                else
                {
                    like.Photo = null;
                }
                _aboutRepository.AddLikeAble(like);
                return(RedirectToAction("index"));
            }
            return(View(model));
        }