示例#1
0
        // PUT: Task/5?tenant_id
        public HttpResponseMessage Put(string tenant_id, int id, [FromBody] DOMAIN.Entities.Task newc)
        {
            DOMAIN.Entities.Task oldc = TaskService.GetById(id);

            if (oldc.Owner != tenant_id)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "You are not allowed, check your tenant id"));
            }

            else
            {
                //ID & Owner are the same on update.

                oldc.TaskName      = newc.TaskName;
                oldc.Description   = newc.Description;
                oldc.Plan          = newc.Plan;
                oldc.Goals         = newc.Goals;
                oldc.Requirement   = newc.Requirement;
                oldc.Tools         = newc.Tools;
                oldc.StartDate     = newc.StartDate;
                oldc.DeadLine      = newc.DeadLine;
                oldc.EstimatedTime = newc.EstimatedTime;
                oldc.Complexity    = newc.Complexity;
                oldc.State         = newc.State;

                oldc.ProjectCode = newc.ProjectCode;

                TaskService.Update(oldc);
                TaskService.Commit();
            }

            return(Request.CreateResponse(HttpStatusCode.OK, "Task updated !"));
        }
示例#2
0
        // POST: Task?tenant_id
        public void Post(string tenant_id, [FromBody] DOMAIN.Entities.Task t)
        {
            //ID = AutoIncrement & Owner = tenant_id.

            t.Owner = tenant_id;
            TaskService.Add(t);
            TaskService.Commit();
        }
示例#3
0
        // DELETE: Task/5?tenant_id
        public HttpResponseMessage Delete(string tenant_id, int id)
        {
            DOMAIN.Entities.Task c = TaskService.GetById(id);

            if (c.Owner != tenant_id)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "You are not allowed, check your tenant id"));
            }

            else
            {
                TaskService.Delete(c);
                TaskService.Commit();
                return(Request.CreateResponse(HttpStatusCode.OK, "Task deleted !"));
            }
        }
示例#4
0
        // GET: /Task/5?tenant-id
        public HttpResponseMessage Get(string tenant_id, int id)
        {
            DOMAIN.Entities.Task t = TaskService.GetById(id);

            if (t == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, "Incorrect task id"));
            }

            else if (t.Owner != tenant_id)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "You are not allowed, check your tenant id"));
            }

            else
            {
                TaskContainer tc = new TaskContainer();

                tc.TaskID        = t.TaskID;
                tc.TaskName      = t.TaskName;
                tc.Description   = t.Description;
                tc.Plan          = t.Plan;
                tc.Goals         = t.Goals;
                tc.Requirement   = t.Requirement;
                tc.Tools         = t.Tools;
                tc.StartDate     = t.StartDate;
                tc.DeadLine      = t.DeadLine;
                tc.EstimatedTime = t.EstimatedTime;
                switch (t.Complexity)
                {
                case ComplexityEnum.Easy:
                    tc.ComplexityString = "Easy";
                    break;

                case ComplexityEnum.Hard:
                    tc.ComplexityString = "Hard";
                    break;

                case ComplexityEnum.Medium:
                    tc.ComplexityString = "Medium";
                    break;

                case ComplexityEnum.VeryHard:
                    tc.ComplexityString = "Very Hard";
                    break;
                }

                switch (t.State)
                {
                case StateEnum.Doing:
                    tc.StateString = "Doing";
                    break;

                case StateEnum.Done:
                    tc.StateString = "Done";
                    break;

                case StateEnum.ToDo:
                    tc.StateString = "To Do";
                    break;
                }

                tc.Project = t.project.ProjectName;

                if (t.TeamLeader.UserType == UserType.TeamLeader)
                {
                    tc.TeamLeader = t.TeamLeader.FullName;
                }
                return(Request.CreateResponse(HttpStatusCode.OK, tc));
            }
        }