public IActionResult AddEvent(EventCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         string uniqueFilename = null;
         if (model.Photo != null)
         {
             string uploadFolder = Path.Combine(_hostingEnvironment.WebRootPath, "images");
             uniqueFilename = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
             string filePath = Path.Combine(uploadFolder, uniqueFilename);
             model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
         }
         ClgEvent @event = new ClgEvent
         {
             Title       = model.Title,
             Category    = model.Category,
             Date        = model.Date,
             Status      = status.New,
             Venue       = model.Venue,
             Description = model.Description,
             PhotoPath   = uniqueFilename
         };
         _eventRepository.AddEvent(@event);
         return(RedirectToAction("EventDetails", new { id = @event.Id, updated = false }));
     }
     return(View());
 }
        public IActionResult DeleteEventConfirmed(int Id)
        {
            ClgEvent clgEvent = _eventRepository.GetEvent(Id);

            _eventRepository.DeleteEvent(clgEvent.Id);
            return(RedirectToAction("ViewEvents"));
        }
        public IActionResult EventDetails(int Id)
        {
            ClgEvent clgEvent = _eventRepository.GetEvent(Id);

            if (clgEvent == null)
            {
                Response.StatusCode = 404;
                return(View("EventNotFound", Id));
            }
            return(View(clgEvent));
        }
        public IActionResult EventDetails(int Id, bool updated)
        {
            if (updated)
            {
                ViewBag.Msg = "Event details updated successfully !!";
            }
            ClgEvent clgEvent = _eventRepository.GetEvent(Id);

            if (clgEvent == null)
            {
                Response.StatusCode = 404;
                return(View("EventNotFound", Id));
            }
            return(View(clgEvent));
        }
 public IActionResult UpdateEvent(ClgEvent model)
 {
     if (ModelState.IsValid)
     {
         ClgEvent clgEvent = _eventRepository.GetEvent(model.Id);
         clgEvent.Title       = model.Title;
         clgEvent.Category    = model.Category;
         clgEvent.Status      = model.Status;
         clgEvent.Date        = model.Date;
         clgEvent.Description = model.Description;
         clgEvent.Venue       = model.Venue;
         ClgEvent updatedEvent = _eventRepository.UpdateEvent(clgEvent);
         return(RedirectToAction("EventDetails", new { id = model.Id, updated = true }));
     }
     return(View(model));
 }
        public ViewResult UpdateEvent(int Id)
        {
            ClgEvent clgEvent = _eventRepository.GetEvent(Id);
            ClgEvent newEvent = new ClgEvent
            {
                Id          = clgEvent.Id,
                Title       = clgEvent.Title,
                Category    = clgEvent.Category,
                Status      = clgEvent.Status,
                Date        = clgEvent.Date,
                Description = clgEvent.Description,
                Venue       = clgEvent.Venue
            };

            return(View(newEvent));
        }