示例#1
0
        public ActionResult EditEvent(int id)
        {
            ViewBag.OrganizerList = new SelectList(db.Organisers.Where(o => o.status == true), "Id", "represent");
            ViewBag.VenueList     = new SelectList(db.Venues, "Id", "name");

            var e = db.Events.Find(id);

            if (e == null)
            {
                return(RedirectToAction("Index", "Admin"));
            }

            var model = new EventEditVM
            {
                Id           = id,
                name         = e.name,
                des          = e.des,
                participants = e.participants,
                price        = e.price,
                date         = e.date,
                startTime    = e.startTime,
                endTime      = e.endTime,
                photoURL     = e.photoURL,
                OrgId        = e.OrgId,
                venueId      = e.venueId
            };

            return(View(model));
        }
示例#2
0
        public ActionResult EditEvent(EventEditVM model)
        {
            var e = db.Events.Find(model.Id);

            if (model == null)
            {
                return(RedirectToAction("Index", "Admin"));
            }
            int duration = ((int)model.endTime.TotalMinutes - (int)model.startTime.TotalMinutes) / 60;

            if (ModelState.IsValid)
            {
                e.name         = model.name;
                e.des          = model.des;
                e.price        = model.price;
                e.availability = model.availability;
                e.participants = model.participants;
                e.startDate    = model.startDate;
                e.endDate      = model.endDate;
                e.startTime    = model.startTime;
                e.endTime      = model.endTime;
                e.duration     = duration.ToString();
                e.approvalStat = true;
                if (model.Photo != null)
                {
                    DeletePhoto(e.photoURL);
                    e.photoURL = SavePhoto(model.Photo);
                }
                e.OrgId = model.OrgId;
                db.SaveChanges();
                TempData["info"] = "Event record updated successfully";
                return(RedirectToAction("DisplayEvent", "Admin"));
            }
            return(View(model));
        }
示例#3
0
        public ActionResult EditEvent(int id)
        {
            ViewBag.OrganizerList = new SelectList(db.Organisers, "Id", "represent");
            var e = db.Events.Find(id);

            if (e == null)
            {
                return(RedirectToAction("Index", "Admin"));
            }

            /*            int duration = ((int)e.endTime.TotalMinutes - (int)e.startTime.TotalMinutes) / 60;
             */
            var model = new EventEditVM
            {
                Id           = id,
                name         = e.name,
                des          = e.des,
                price        = e.price,
                availability = e.availability,
                participants = e.participants,
                startDate    = e.startDate,
                endDate      = e.endDate,
                startTime    = e.startTime,
                endTime      = e.endTime,
                duration     = e.duration,
                approvalStat = true,
                photoURL     = e.photoURL,
                OrgId        = e.OrgId
            };

            return(View(model));
        }
示例#4
0
        public async Task <IActionResult> EventEdit(int EventID)
        {
            var response = await _eventiApi.GetEventAsync(EventID);

            var Event = response.Content;

            var model = new EventEditVM()
            {
                ID                    = Event.ID,
                Name                  = Event.Name,
                Description           = Event.Description,
                Start                 = Event.Start,
                End                   = Event.Start,
                EventCategorySelected = (int)Event.EventCategory
            };

            return(View(model));
        }
示例#5
0
        public async Task <IActionResult> EditEventSave(EventEditVM model)
        {
            var response = await _eventiApi.GetEventAsync(model.ID);

            var e = response.Content;

            var request = new EventUpdateRequest()
            {
                Name          = model.Name,
                Description   = model.Description,
                Start         = model.Start,
                End           = model.End,
                EventCategory = (EventCategory)model.EventCategorySelected
            };

            await _eventiApi.UpdateEventAsync(model.ID, request);


            return(Redirect("EventInfoPrikaz?EventID=" + model.ID.ToString()));
        }
示例#6
0
        public ActionResult EditEvent(EventEditVM model)
        {
            var e = db.Events.Find(model.Id);

            ViewBag.OrganizerList = new SelectList(db.Organisers.Where(o => o.status == true), "Id", "represent");
            ViewBag.VenueList     = new SelectList(db.Venues, "Id", "name");
            if (ModelState.IsValidField("startTime"))
            {
                if (model.startTime > model.endTime)
                {
                    ModelState.AddModelError("startTime", "start time cannot exceed or equal end time!");
                }
            }
            if (model == null)
            {
                return(RedirectToAction("Index", "Admin"));
            }
            if (ModelState.IsValid)
            {
                e.name         = model.name;
                e.des          = model.des;
                e.price        = model.price;
                e.participants = e.participants;
                e.availability = e.availability;
                e.date         = model.date;
                e.startTime    = model.startTime;
                e.endTime      = model.endTime;
                e.approvalStat = true;
                if (model.Photo != null)
                {
                    DeletePhoto(e.photoURL);
                    e.photoURL = SavePhoto(model.Photo);
                }
                e.OrgId   = model.OrgId;
                e.venueId = model.venueId;
                db.SaveChanges();
                TempData["info"] = "Event record updated successfully";
                return(RedirectToAction("DisplayEvent", "Admin"));
            }
            return(View(model));
        }
        // GET: Events/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Event taevent = db.Events.Find(id);

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

            short       infoid = taevent.InfoId;
            Info        info   = db.Infos.Find(infoid);
            EventEditVM model  = new EventEditVM(taevent, info);

            List <short> selectedTags = db.InfoTags.Where(t => t.InfoId == infoid).Select(t => t.TagId).ToList();

            ViewBag.Selected = selectedTags;
            ViewBag.Tags     = db.Tags.ToList();

            return(View(model));
        }
        public ActionResult Edit([Bind(Include = "EventId,InfoId,Name,IsHistory,AboutText,NormalParticipants,IsPublished,DateMonth,DateSeason, Blurb, IsSecret")] EventEditPostVM taevent,
                                 List <short> tags,
                                 string submit)
        {
            if (ModelState.IsValid)
            {
                #region Save or Publish?
                switch (submit)
                {
                case "Save Progress":
                case "Un-Publish":
                    taevent.IsPublished = false;
                    break;

                case "Publish":
                case "Save":
                    taevent.IsPublished = true;
                    break;

                case "Save and go to complex edit":
                    break;
                }
                #endregion

                var infoid = taevent.InfoId;
                #region Info Update
                //Info info = db.Infos.Find(infoid);
                Info info = db.Infos.Where(i => i.InfoId == infoid).FirstOrDefault();
                info.Name        = taevent.Name;
                info.Blurb       = taevent.Blurb;
                info.IsPublished = taevent.IsPublished;
                info.IsSecret    = taevent.IsSecret;
                #endregion

                #region Update tags
                List <short> currentTagIds = db.InfoTags.Where(x => x.InfoId == infoid).Select(x => x.TagId).ToList();

                if (tags != null)
                {
                    foreach (short tag in tags)
                    {
                        //if this is an already existing tag
                        if (currentTagIds.Contains(tag))
                        {
                            currentTagIds.Remove(tag);
                        }
                        //if this is a newly added tag
                        else
                        {
                            InfoTag newTag = new InfoTag {
                                InfoId = infoid, TagId = tag
                            };
                            db.InfoTags.Add(newTag);
                        }
                    }
                }

                if (currentTagIds.Count != 0)
                {
                    foreach (short id in currentTagIds)
                    {
                        InfoTag gone = db.InfoTags.Where(x => x.InfoId == infoid & x.TagId == id).FirstOrDefault();
                        db.InfoTags.Remove(gone);
                    }
                }

                #endregion

                #region Update Event
                Event daEvent = new Event
                {
                    InfoId             = taevent.InfoId,
                    EventId            = taevent.EventId,
                    Name               = taevent.Name,
                    IsHistory          = taevent.IsHistory,
                    AboutText          = taevent.AboutText,
                    NormalParticipants = taevent.NormalParticipants,
                    IsPublished        = taevent.IsPublished,
                    DateMonth          = taevent.DateMonth,
                    DateSeason         = taevent.DateSeason
                };
                db.Entry(daEvent).State = EntityState.Modified;
                db.Entry(info).State    = EntityState.Modified;
                db.SaveChanges();
                #endregion
                if (submit == "Save and go to complex edit")
                {
                    return(RedirectToAction("AssoEdit", new { id = taevent.EventId }));
                }
                return(RedirectToAction("Details", new { id = taevent.EventId }));
            }

            //if model invalid
            ViewBag.Tags = db.Tags.ToList();
            if (tags != null)
            {
                ViewBag.Selected = tags;
            }
            else
            {
                ViewBag.Selected = new List <short>();
            }
            ModelState.AddModelError("", "Something has gone wrong. Look for red text to see where is went wrong");
            EventEditVM aEvent = new EventEditVM(taevent);
            return(View(aEvent));
        }