// POST api/userevents public ReturnValue Post([FromBody] UserEventCreate value) { if (value == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } ReturnValue returnValue = new ReturnValue(); try { var serializer = new JavaScriptSerializer(); var serializedResult = serializer.Serialize(value.PhoneHash); returnValue.value = entity.UserEventCreate(value.UserSN, value.Catogory, value.CatogoryName, serializedResult); returnValue.code = 0; returnValue.msg = "succes"; } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } return(returnValue); }
public bool JoinUserEvent(UserEventCreate model) { UserProfile userProfile = _db.UserProfiles.Single(up => up.OwnerId == _userId); UserEvent userEvent = new UserEvent() { EventId = model.EventId, ProfileId = userProfile.ProfileId }; _db.UserEvents.Add(userEvent); return(_db.SaveChanges() == 1); }
public bool CreateUserEvent(UserEventCreate model) { var entity = new UserEvent() { EventId = model.EventId, ProfileId = model.ProfileId }; using (var ctx = new ApplicationDbContext()) { ctx.UserEvents.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(UserEventCreate model) { if (!ModelState.IsValid) { return(View(ModelState)); } var service = CreateUserEventService(); if (service.CreateUserEvent(model)) { return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Join(UserEventCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateEventService(); if (service.JoinUserEvent(model)) { TempData["SaveResult"] = "This event has been added to your profile."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "This event could not be added to your profile."); return(View(model)); }