예제 #1
0
 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();
     }
 }
예제 #2
0
 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();
     }
 }
예제 #3
0
 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();
     }
 }
예제 #4
0
 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();
         }
     }
 }
예제 #5
0
 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();
     }
 }
예제 #6
0
        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();
            }
        }
예제 #7
0
 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();
     }
 }