コード例 #1
0
ファイル: PeopleController.cs プロジェクト: kilicsule/NeOldu
        public async Task <IActionResult> EditConfirmed(PeopleCEViewModel model)
        {
            if (ModelState.IsValid)
            {
                var entity = UnitOfWork.PeopleDal.GetById(model.Id);
                entity.FirstName = model.FirstName;
                entity.LastName  = model.LastName;
                UnitOfWork.FileManager.ImageDelete(model.ImagePath);
                entity.Image = await UnitOfWork.FileManager.FileImageSaveAsync(model.Image);

                entity.Title        = model.Title;
                entity.News         = model.News;
                entity.Detail       = model.Detail;
                entity.Description  = model.Description;
                entity.DeathDateId  = model.DeathDateId;
                entity.ByWhom       = model.ByWhom;
                entity.WhyKilled    = model.WhyKilled;
                entity.PlaceDeath   = model.PlaceDeath;
                entity.Subject      = model.Subject;
                entity.IsProtection = model.IsProtection;
                entity.SourceLink   = model.SourceLink;
                entity.WayKilled    = model.WayKilled;
                UnitOfWork.Commit();
                return(RedirectToAction("Index", "People"));
            }
            ViewBag.DeathDate = UnitOfWork.DeathDateDal.GetQueryable().OrderBy(p => p.Year)
                                .Select(a => new SelectListItem()
            {
                Value = a.Id.ToString(), Text = a.Year.ToString()
            }).ToList();
            return(View());
        }
コード例 #2
0
ファイル: PeopleController.cs プロジェクト: kilicsule/NeOldu
        public IActionResult Edit(Guid id)
        {
            var model = UnitOfWork.PeopleDal.GetById(id);

            ViewBag.DeathDate = UnitOfWork.DeathDateDal.GetQueryable().OrderBy(p => p.Year)
                                .Select(a => new SelectListItem()
            {
                Value = a.Id.ToString(), Text = a.Year.ToString()
            }).ToList();
            var People = new PeopleCEViewModel()
            {
                Id           = model.Id,
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                Description  = model.Description,
                Detail       = model.Detail,
                News         = model.News,
                Title        = model.Title,
                DeathDateId  = model.DeathDateId,
                ByWhom       = model.ByWhom,
                WhyKilled    = model.WhyKilled,
                PlaceDeath   = model.PlaceDeath,
                Subject      = model.Subject,
                IsProtection = model.IsProtection,
                SourceLink   = model.SourceLink,
                WayKilled    = model.WayKilled
            };

            return(View(People));
        }
コード例 #3
0
        public async Task <IActionResult> CreateConfirmed(PeopleCEViewModel model)
        {
            if (ModelState.IsValid)
            {
                var People = new People()
                {
                    Id           = Guid.NewGuid(),
                    FirstName    = model.FirstName,
                    LastName     = model.LastName,
                    Description  = model.Description,
                    Detail       = model.Detail,
                    News         = model.News,
                    Title        = model.Title,
                    DeathDateId  = model.DeathDateId,
                    ByWhom       = model.ByWhom,
                    WhyKilled    = model.WhyKilled,
                    PlaceDeath   = model.PlaceDeath,
                    Subject      = model.Subject,
                    IsProtection = model.IsProtection,
                    SourceLink   = model.SourceLink,
                    WayKilled    = model.WayKilled
                };
                People.Image = await FileManager.FileImageSaveAsync(model.Image);

                UnitOfWork.PeopleRepository.Add(People);
                UnitOfWork.Commit();
                return(RedirectToAction("Index", "People"));
            }
            ViewBag.DeathDate = UnitOfWork.DeathDateRepository.GetQueryable().OrderBy(p => p.Year)
                                .Select(a => new SelectListItem()
            {
                Value = a.Id.ToString(), Text = a.Year.ToString()
            }).ToList();
            return(View());
        }