/// <summary> /// Insert a new task status /// REQUIRES: Admin access to role /// </summary> /// <param name="roleId">The role</param> /// <param name="taskStatus">The status</param> public void Post(Guid roleId, TaskStatus taskStatus) { var businessAccount = CoreEntitiesContainer.Owner(roleId, new[] { RoleType.Administrator }).Include(ba => ba.TaskStatuses).FirstOrDefault(); if (businessAccount == null) throw Request.NotAuthorized(); var status = TaskStatus.CreateFromModel(taskStatus); status.CreatedDate = DateTime.UtcNow; status.LastModifyingUserId = CoreEntitiesContainer.CurrentUserAccount().Id; businessAccount.TaskStatuses.Add(status); SaveWithRetry(); }
/// <summary> /// Update a task status /// REQUIRES: Admin access to role /// </summary> /// <param name="roleId">The role</param> /// <param name="taskStatus">The status</param> public void Put(Guid roleId, TaskStatus taskStatus) { var businessAccount = CoreEntitiesContainer.Owner(roleId, new[] { RoleType.Administrator }).Include(ba => ba.TaskStatuses).FirstOrDefault(); if (businessAccount == null) throw Request.NotAuthorized(); var original = CoreEntitiesContainer.TaskStatuses.FirstOrDefault(ts => ts.Id == taskStatus.Id); if (original == null) throw Request.NotFound(); //update the status original.Color = taskStatus.Color; original.DefaultTypeInt = taskStatus.DefaultTypeInt; original.Name = taskStatus.Name; original.RemoveFromRoute = taskStatus.RemoveFromRoute; //TODO CR Make extension method on ITrackable to do this original.LastModified = DateTime.UtcNow; original.LastModifyingUserId = CoreEntitiesContainer.CurrentUserAccount().Id; SaveWithRetry(); }