示例#1
0
        public ActionResult Update(MahfilFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Genres = _context.Genres.ToList();
                return(View("CongregrationForm", model));
            }

            var congregration = _mahfilMepository.GetMahfilWithAttendees(model.Id);

            if (congregration == null)
            {
                return(HttpNotFound());
            }

            if (congregration.SpeakerId != User.Identity.GetUserId())
            {
                return(new HttpUnauthorizedResult());
            }
            congregration.Venue    = model.Venue;
            congregration.DateTime = model.GetDateTime();
            congregration.GenreId  = model.Genre;
            _context.SaveChanges();
            return(RedirectToAction("Mine", "Mahfil"));
        }
示例#2
0
        public ActionResult Edit(string id)
        {
            var congregration = _mahfilMepository.GetMahfil(id);

            if (congregration == null)
            {
                return(HttpNotFound());
            }
            if (congregration.SpeakerId != User.Identity.GetUserId())
            {
                return(new HttpUnauthorizedResult());
            }
            var viewModel = new MahfilFormViewModel()
            {
                Id      = congregration.Id,
                Heading = "Edit Congregration",
                Genres  = _context.Genres.ToList(),
                Date    = congregration.DateTime.ToString("MM/dd/yyyy"),
                Time    = congregration.DateTime.ToString("HH:mm"),
                Genre   = congregration.GenreId,
                Venue   = congregration.Venue
            };

            return(View("CongregrationForm", viewModel));
        }
示例#3
0
        public ActionResult Create(MahfilFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Genres = _genreRepository.GetGenres();
                return(View("CongregrationForm", model));
            }
            var speakerId = User.Identity.GetUserId();
            //var speaker = _context.Users.Single(x => x.Id == speakerId);
            //var genre = _context.Genres.Single(x => x.Id == model.Genre);
            var mahfil = new Congregration()
            {
                Id        = Guid.NewGuid().ToString(),
                SpeakerId = speakerId,
                //Speaker = speaker,
                DateTime = model.GetDateTime(),
                //Genre = genre,
                GenreId = model.Genre,
                Venue   = model.Venue
            };

            _mahfilMepository.Add(mahfil);
            _unitOfWork.Complete();
            return(RedirectToAction("Mine", "Mahfil"));
        }
示例#4
0
        public ActionResult Create()
        {
            var viewModel = new MahfilFormViewModel()
            {
                Id      = "",
                Genres  = _context.Genres.ToList(),
                Heading = "Add new Congregration"
            };

            return(View("CongregrationForm", viewModel));
        }