public List<Group> getGroupsByHobby(Hobby h) { var groups = (from c in db.HobbyGroupConnections where h.ID == c.HobbyID join g in db.Groups on c.GroupID equals g.ID select g).ToList(); return groups; }
public bool addHobbyToStatus(Status s, Hobby toAdd) { StatusHobbyConnection sConnection = new StatusHobbyConnection(); sConnection.StatusID = s.ID; sConnection.HobbyID = toAdd.ID; db.StatusHobbyConnections.Add(sConnection); return db.SaveChanges() != 0; }
public bool addHobbyToUser(ApplicationUser a, Hobby toAdd) { UserHobbyConnection hConnection = new UserHobbyConnection(); hConnection.UserID = a.Id; hConnection.HobbyID = toAdd.ID; db.UserHobbyConnections.Add(hConnection); return db.SaveChanges() != 0; }
public bool addHobbyGroupConnection(Hobby h, Group g) { HobbyGroupConnection hConnection = new HobbyGroupConnection(); hConnection.GroupID = g.ID; hConnection.HobbyID = h.ID; db.HobbyGroupConnections.Add(hConnection); return db.SaveChanges() != 0; }
public bool addHobby(Hobby h) { db.Hobbies.Add(h); return db.SaveChanges() != 0; }
public bool removeHobbyFromuser(ApplicationUser a, Hobby toDel) { UserHobbyConnection hConnection = getUserHobbyConnection(a, toDel); db.UserHobbyConnections.Remove(hConnection); return db.SaveChanges() != 0; }
public bool removeHobby(Hobby h) { db.Hobbies.Remove(h); return db.SaveChanges() != 0; }
public List<ApplicationUser> getUsersByHobby(Hobby h) { var users = (from c in db.UserHobbyConnections where c.HobbyID == h.ID join u in db.Users on c.UserID equals u.Id select u).ToList(); return users; }
public UserHobbyConnection getUserHobbyConnection(ApplicationUser a, Hobby h) { var hConnection = (from c in db.UserHobbyConnections where c.HobbyID == h.ID && c.UserID == a.Id select c).SingleOrDefault(); return hConnection; }
public bool removeHobbyFromStatus(Status s, Hobby toDel) { StatusHobbyConnection sConnection = new StatusHobbyConnection(); sConnection.StatusID = s.ID; sConnection.HobbyID = toDel.ID; db.StatusHobbyConnections.Remove(sConnection); return db.SaveChanges() != 0; }
public List<Status> getStatusesByHobby(Hobby h) { var statuses = (from c in db.StatusHobbyConnections where c.HobbyID == h.ID join s in db.Statuses on c.StatusID equals s.ID orderby s.Date descending select s).ToList(); return statuses; }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Username, Email = model.Email, ProfilePic = "http://i.imgur.com/Ov81kK0.jpg", Karma = 0, NumberOfFollowers = 0, NumberOfFollowing = 0 }; if (hobbyService.getDefaultHobby() == null) { var defaultHobby = new Hobby(); defaultHobby.Name = "Misc"; hobbyService.addHobby(defaultHobby); } hobbyService.addHobbyToUser(user, hobbyService.getDefaultHobby()); var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return RedirectToAction("Index", "Home"); } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }