示例#1
0
        public HttpResponseMessage Put(Core.Goal goal)
        {
            try
            {
                repository.UpdateGoal(goal);
                response.StatusCode = HttpStatusCode.OK;
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(response);
        }
示例#2
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();
         }
     }
 }
示例#3
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();
     }
 }
示例#4
0
        public Core.Goal GetGoal(int id)
        {
            Core.Goal goal = null;
            using (var context = new GoalsContext())
            {
                goal = context.Goals
                       .Where(g => g.GoalId == id)
                       .Select(g => new Core.Goal
                {
                    GoalId       = g.GoalId,
                    Title        = g.Title,
                    Description  = g.Description,
                    StartDate    = g.StartDate,
                    EndDate      = g.EndDate,
                    ReviewerId   = g.ReviewerId,
                    ReviewerName = g.Reviewer.FirstName + " " + g.Reviewer.LastName,
                    Status       = g.Status,
                    UserId       = g.UserId,
                    UserName     = g.User.FirstName + " " + g.User.LastName
                }).FirstOrDefault();
            }

            return(goal);
        }
示例#5
0
        static void Main(string[] args)
        {
            Repository rep = new Repository();

            var country = new Core.Country
            {
                CountryId = 1,
                Name      = "United States"
            };

            rep.AddCountry(country);

            var city = new Core.City
            {
                CityId    = 1,
                Name      = "Raccoon City",
                CountryId = rep.GetCountries().FirstOrDefault().CountryId
            };

            rep.AddCity(city);

            var project = new Core.Project
            {
                ProjectId = 1,
                Name      = "Market Forward"
            };

            rep.AddProject(project);

            var user = new Core.User
            {
                UserId    = 1,
                UserName  = "******",
                Password  = "******",
                FirstName = "Leon",
                LastName  = "Kennedy",
                ProjectId = rep.GetProjects().FirstOrDefault().ProjectId,
                CityId    = rep.GetCities().FirstOrDefault().CityId,
                Portrait  = "LeonKennedy.jpg",
                CanReview = false
            };

            rep.AddUser(user);

            var user2 = new Core.User
            {
                UserId    = 2,
                UserName  = "******",
                Password  = "******",
                FirstName = "Claire",
                LastName  = "Redfield",
                ProjectId = rep.GetProjects().FirstOrDefault().ProjectId,
                CityId    = rep.GetCities().FirstOrDefault().CityId,
                Portrait  = "ClaireRedfield.jpg",
                CanReview = true
            };

            rep.AddUser(user2);

            var user3 = new Core.User
            {
                UserName  = "******",
                Password  = "******",
                FirstName = "Ada",
                LastName  = "Wong",
                ProjectId = rep.GetProjects().FirstOrDefault().ProjectId,
                CityId    = rep.GetCities().FirstOrDefault().CityId,
                Portrait  = "AdaWong.jpg",
                CanReview = true
            };

            rep.AddUser(user3);

            var users = rep.GetUsers();

            List <int> userIds = new List <int>();

            foreach (var u in rep.GetUsers())
            {
                userIds.Add(u.UserId);
            }

            var goal = new Core.Goal
            {
                GoalId      = 1,
                UserId      = userIds[0],
                Title       = "Angular",
                Description = "Learn angular 1.5 and create a proof of concept",
                StartDate   = DateTime.Now,
                EndDate     = DateTime.Now,
                Status      = 1,
                ReviewerId  = rep.GetUsers().Where(u => u.CanReview).FirstOrDefault().UserId
            };

            rep.AddGoal(goal);

            var goal2 = new Core.Goal
            {
                GoalId      = 1,
                UserId      = userIds[0],
                Title       = "Xamarin",
                Description = "Learn Xamarin and create an application",
                StartDate   = DateTime.Now,
                EndDate     = DateTime.Now,
                Status      = 1,
                ReviewerId  = rep.GetUsers().Where(u => u.CanReview).FirstOrDefault().UserId
            };

            rep.AddGoal(goal2);

            var goal3 = new Core.Goal
            {
                GoalId      = 1,
                UserId      = userIds[1],
                Title       = "React",
                Description = "Learn React 1.5 and create a proof of concept",
                StartDate   = DateTime.Now,
                EndDate     = DateTime.Now,
                Status      = 1,
                ReviewerId  = rep.GetUsers().Where(u => u.CanReview).FirstOrDefault().UserId
            };

            rep.AddGoal(goal3);

            var goal4 = new Core.Goal
            {
                GoalId      = 1,
                UserId      = userIds[1],
                Title       = "TypeScript",
                Description = "Learn TypeScript and create an application",
                StartDate   = DateTime.Now,
                EndDate     = DateTime.Now,
                Status      = 1,
                ReviewerId  = rep.GetUsers().Where(u => u.CanReview).FirstOrDefault().UserId
            };

            rep.AddGoal(goal4);

            var goal5 = new Core.Goal
            {
                GoalId      = 1,
                UserId      = userIds[2],
                Title       = "JQuery",
                Description = "Learn JQuery and create a project",
                StartDate   = DateTime.Now,
                EndDate     = DateTime.Now,
                Status      = 1,
                ReviewerId  = rep.GetUsers().Where(u => u.CanReview).FirstOrDefault().UserId
            };

            rep.AddGoal(goal5);

            var goal6 = new Core.Goal
            {
                GoalId      = 1,
                UserId      = userIds[2],
                Title       = "JS",
                Description = "Learn advanced javascript an create a proof of concept",
                StartDate   = DateTime.Now,
                EndDate     = DateTime.Now,
                Status      = 1,
                ReviewerId  = rep.GetUsers().Where(u => u.CanReview).FirstOrDefault().UserId
            };

            rep.AddGoal(goal6);


            var goals = rep.GetGoals();
        }