示例#1
0
        public IHttpActionResult Post(MeetCreate meet)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateMeetService();

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

            return(Ok());
        }
示例#2
0
        public bool CreateMeet(MeetCreate model)
        {
            var entity = new Meet()
            {
                OwnerID           = _userID,
                LocationOfMeet    = model.LocationOfMeet,
                DescriptionOfMeet = model.DescriptionOfMeet,
                DateOfMeet        = model.DateOfMeet,
                DateCreated       = DateTimeOffset.Now
            };


            using (var ctx = new ApplicationDbContext())
            {
                ctx.Meets.Add(entity);
                return(ctx.SaveChanges() == 1);
            };
        }
示例#3
0
        public ActionResult Create(MeetCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateMeetService();

            if (service.CreateMeet(model))
            {
                TempData["SaveResult"] = "Your Meet Has Successfully Been Created!";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Meet Could Not Be Made");
            return(View(model));
        }