public static void Activate(User user) { var entity = new CreativeNetworkEntities(); var userToChange = entity.User.FirstOrDefault(a => a.Id == user.Id); if (userToChange != null) userToChange.IsBlock = false; entity.SaveChanges(); }
public static void AddUser(User user) { var entity = new CreativeNetworkEntities(); entity.User.Add(user); entity.SaveChanges(); }
public static void Rate(User user, Creative creative, int rating) { var entity = new CreativeNetworkEntities(); var creativeLikes = entity.CreativeLikes.FirstOrDefault(a => a.UserId == user.Id && a.CreativeId == creative.Id); if (creativeLikes != null) { if (creativeLikes.Rating == rating) { entity.CreativeLikes.Remove(creativeLikes); entity.SaveChanges(); return; } else { entity.CreativeLikes.Remove(creativeLikes); } } var newRate = new CreativeLikes() { UserId = user.Id, CreativeId = creative.Id, Rating = rating, }; entity.CreativeLikes.Add(newRate); entity.SaveChanges(); }
public static Creative[] GetCreatives(User user) { var entity = new CreativeNetworkEntities(); return entity.Creative.Where(a => a.User.Id == user.Id).ToArray(); }