public DataModel.WorkItemGroupEntity GetWorkItemGroupById(int id)
 {
     var data = db.WorkItemGroups.FirstOrDefault(c => c.WorkItemGroupId == id);
     if (data != null)
     {
         WorkItemGroupEntity workItemGroup = new WorkItemGroupEntity();
         workItemGroup.WorkItemGroupId = data.WorkItemGroupId;
         workItemGroup.Description = data.Description;
         workItemGroup.OrderNumber = data.OrderNumber;
         workItemGroup.ProjectId = data.ProjectId;
         workItemGroup.Project = new ProjectRepositiory().GetProjectById(data.ProjectId);
         return workItemGroup;
     }
     return null;
 }
        public IEnumerable<DataModel.WorkItemGroupEntity> GetAll()
        {
            List<WorkItemGroupEntity> workItemsGroups = new List<WorkItemGroupEntity>();
            foreach (var data in db.WorkItemGroups)
            {
                WorkItemGroupEntity workItemGroup = new WorkItemGroupEntity();
                workItemGroup.WorkItemGroupId = data.WorkItemGroupId;
                workItemGroup.Description = data.Description;
                workItemGroup.OrderNumber = data.OrderNumber;
                workItemGroup.ProjectId = data.ProjectId;
                workItemGroup.WorkItems = new WorkItemRepository().GetWorkItemsByWorkItemGroupId(data.WorkItemGroupId);
                workItemsGroups.Add(workItemGroup);
            }

            return workItemsGroups;
        }
        public IEnumerable<WorkItemGroupEntity> GetWorkItemGroupsByProjectId(int projectId)
        {
            List<WorkItemGroupEntity> workItemsGroups = new List<WorkItemGroupEntity>();
            var WorkItemGroups = db.WorkItemGroups.Where(c => c.ProjectId == projectId);
            if (WorkItemGroups != null)
            {
                foreach (var data in WorkItemGroups.OrderBy(q => q.OrderNumber))
                {
                    WorkItemGroupEntity workItemGroup = new WorkItemGroupEntity();
                    workItemGroup.WorkItemGroupId = data.WorkItemGroupId;
                    workItemGroup.Description = data.Description;
                    workItemGroup.OrderNumber = data.OrderNumber;
                    workItemGroup.ProjectId = data.ProjectId;
                    workItemGroup.WorkItems = new WorkItemRepository().GetWorkItemsByWorkItemGroupId(data.WorkItemGroupId);
                    workItemsGroups.Add(workItemGroup);
                }
            }

            return workItemsGroups;
        }
        // POST api/WorkItemGroup
        public HttpResponseMessage PostWorkItemGroup(WorkItemGroupEntity workitemgroup)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
            if (workitemgroup == null)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            try
            {
                dbContext.AddWorkItemGroup(workitemgroup);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }