public void AddProject(Core.Project newProject) { using (var context = new GoalsContext()) { var project = new Project { ProjectId = newProject.ProjectId, Name = newProject.Name }; context.Projects.Add(project); context.SaveChanges(); } }
public void AddCountry(Core.Country newCountry) { using (var context = new GoalsContext()) { var country = new Country { CountryId = newCountry.CountryId, Name = newCountry.Name }; context.Countries.Add(country); context.SaveChanges(); } }
public void AddCity(Core.City newCity) { using (var context = new GoalsContext()) { var city = new City { CityId = newCity.CityId, Name = newCity.Name, CountryId = newCity.CountryId }; context.Cities.Add(city); context.SaveChanges(); } }
public void UpdateGoal(Core.Goal goal) { using (var context = new GoalsContext()) { Goal oldGoal = context.Goals.SingleOrDefault(g => g.GoalId == goal.GoalId); if (oldGoal != null) { oldGoal.Title = goal.Title; oldGoal.Description = goal.Description; oldGoal.StartDate = goal.StartDate; oldGoal.EndDate = goal.EndDate; oldGoal.ReviewerId = goal.ReviewerId; oldGoal.Status = goal.Status; oldGoal.UserId = goal.UserId; context.SaveChanges(); } } }
public void AddGoal(Core.Goal newGoal) { using (var context = new GoalsContext()) { var goal = new Goal { Title = newGoal.Title, Description = newGoal.Description, StartDate = newGoal.StartDate, EndDate = newGoal.EndDate, ReviewerId = newGoal.ReviewerId, Status = newGoal.Status, UserId = newGoal.UserId }; context.Goals.Add(goal); context.SaveChanges(); } }
public void UpdateUser(Core.User user) { using (var context = new GoalsContext()) { var oldUser = context.Users.SingleOrDefault(u => u.UserId == user.UserId); oldUser.UserName = user.UserName; oldUser.FirstName = user.FirstName; oldUser.Password = user.Password; oldUser.LastName = user.LastName; oldUser.CityId = user.CityId; oldUser.Portrait = user.Portrait; oldUser.CanReview = user.CanReview; oldUser.ProjectId = user.ProjectId; context.SaveChanges(); } }
public void AddUser(Core.User newUser) { using (var context = new GoalsContext()) { var user = new User { UserName = newUser.UserName, FirstName = newUser.FirstName, Password = newUser.Password, LastName = newUser.LastName, CityId = newUser.CityId, Portrait = newUser.Portrait, CanReview = newUser.CanReview, ProjectId = newUser.ProjectId }; context.Users.Add(user); context.SaveChanges(); } }