示例#1
0
        // GET: Meet/Edit
        public ActionResult Edit(int id)
        {
            var service = CreateMeetService();
            var detail  = service.GetMeetByID(id);
            var model   = new MeetEdit
            {
                MeetID            = detail.MeetID,
                LocationOfMeet    = detail.LocationOfMeet,
                DescriptionOfMeet = detail.DescriptionOfMeet,
                DateOfMeet        = detail.DateOfMeet
            };

            return(View(model));
        }
示例#2
0
        public bool UpdateMeet(MeetEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Meets.Single
                                 (e => e.MeetID == model.MeetID);
                {
                    entity.MeetID            = model.MeetID;
                    entity.LocationOfMeet    = model.LocationOfMeet;
                    entity.DescriptionOfMeet = model.DescriptionOfMeet;
                    entity.DateOfMeet        = model.DateOfMeet;

                    return(ctx.SaveChanges() == 1);
                }
            }
        }
示例#3
0
        public IHttpActionResult Put(MeetEdit meet)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateMeetService();

            if (!service.UpdateMeet(meet))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
示例#4
0
        public ActionResult Edit(int id, MeetEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.MeetID != id)
            {
                ModelState.AddModelError("", "The ID's Do No Match");
                return(View(model));
            }

            var service = CreateMeetService();

            if (service.UpdateMeet(model))
            {
                TempData["SaveResult"] = "Your Meet Was Updated!";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Nothing Was Changed, Please Enter Your Changes.");
            return(View(model));
        }