public UserActionPoint AddUserActionPoint(UserActionPoint userActionPoint) { var userActionPointId = _repo.Add(this.ConvertUserActionPointToListItem(userActionPoint), ListNames.USER_ACTION_POINTS_LIST).Id; userActionPoint.Id = userActionPointId; return(userActionPoint); }
private UserActionPoint ConvertListItemToUAP(ListItem item) { UserActionPoint userActionPoint = new UserActionPoint { Id = item.Id, Title = (string)item[SiteColumnNames.TITLE], Resources = (string)item[SiteColumnNames.RESOURCES], Description = (string)item[SiteColumnNames.DESCRIPTION], Status = new ItemStatus(item[SiteColumnNames.STATUS].ToString()) }; return(userActionPoint); }
private ListItem ConvertUserActionPointToListItemUpdate(int id, UserActionPoint userActionPoint) { var list = _repo.GetClientContext().Web.Lists.GetByTitle(ListNames.USER_ACTION_POINTS_LIST); ListItem newItem = list.GetItemById(id); newItem[SiteColumnNames.TITLE] = userActionPoint.Title; newItem[SiteColumnNames.DESCRIPTION] = userActionPoint.Description; newItem[SiteColumnNames.RESOURCES] = userActionPoint.Resources; newItem[SiteColumnNames.STATUS] = userActionPoint.Status.Value; newItem.Update(); return(newItem); }
private ListItem ConvertUserActionPointToListItem(UserActionPoint userActionPoint) { var list = _repo.GetClientContext().Web.Lists.GetByTitle( ListNames.USER_ACTION_POINTS_LIST); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem newItem = list.AddItem(itemCreateInfo); newItem[SiteColumnNames.TITLE] = userActionPoint.Title; newItem[SiteColumnNames.DESCRIPTION] = userActionPoint.Description; newItem[SiteColumnNames.RESOURCES] = userActionPoint.Resources; newItem[SiteColumnNames.STATUS] = userActionPoint.Status.Value; newItem[SiteColumnNames.TRAINEE] = Email; newItem.Update(); return(newItem); }
public HttpResponseMessage Post([FromBody] UserActionPoint userActionPoint) { try { if (ModelState.IsValid) { _userActionPointProvider.SetEmail((string)HttpContext.Current.Items["email"]); return(Request.CreateResponse(HttpStatusCode.OK, _userActionPointProvider.AddUserActionPoint(userActionPoint))); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Put(int id) { try { UserActionPoint userActionPoint = _userActionPointProvider.GetUserActionPoint(id); if (ModelState.IsValid) { _userActionPointProvider.SetEmail((string)HttpContext.Current.Items["email"]); return(Request.CreateResponse(HttpStatusCode.OK, _userActionPointProvider.UpdateUserActionPoint(id, userActionPoint))); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
private List <UserSkill> ConvertSkillsToUserSkills(List <Skill> skills) { var lookupValuesSkills = new List <UserSkill>(); foreach (Skill skill in skills) { UserSkill userSkill = new UserSkill(); var actionPoints = skill.ActionPoints; var subSkills = skill.SubSkills; var userActionPoints = new List <UserActionPoint>(); foreach (ActionPoint ap in actionPoints) { var uAp = new UserActionPoint { Title = ap.Title, Resources = ap.Resources, Status = ItemStatus.InProgress, Description = ap.Description }; uAp = _userActionPointProvider.AddUserActionPoint(uAp); userActionPoints.Add(uAp); } var userSkills = ConvertSkillsToUserSkills(subSkills); userSkill.Title = skill.Title; userSkill.Status = ItemStatus.InProgress; userSkill.Level = skill.Level; userSkill.SubSkills = userSkills; userSkill.ActionPoints = userActionPoints; userSkill.Description = skill.Description; userSkill.Id = _userSkillProvider.AddUserSkill(userSkill).Id; lookupValuesSkills.Add(userSkill); } return(lookupValuesSkills); }
public string UpdateUserActionPoint(int id, UserActionPoint userActionPoint) { userActionPoint.Status.Value = ItemStatus.Done.Value; _repo.Update(id, this.ConvertUserActionPointToListItemUpdate(id, userActionPoint), ListNames.USER_ACTION_POINTS_LIST); return("Update succesful for user action point!"); }