// GET: Initiative/Properties/5 public ActionResult Properties(string id) { if (id == null) { throw new ArgumentNullException("id", "No initiative id provided."); } var initiative = GetInitiativeViewModel(id); var model = new InitiativeViewModel { Id = initiative.Id, Name = initiative.Name, UniqueIdentifier = id }; return(View(model)); }
public static InitiativeViewModel ToModel(this IInitiative item, IEnumerable <string> allInitiativeNames) { var dateCreated = (item.ApplicationGroups.SelectMany(x => x.Applications)).Select(y => y.FirstRegistered).OrderBy(z => z.Date).FirstOrDefault(); var response = new InitiativeViewModel { Id = item.Id, Name = item.Name, ClientToken = item.ClientToken, OwnerDeveloperName = item.OwnerDeveloperName, DeveloperRoles = item.DeveloperRoles.Select(x => x.ToModel()).ToArray(), ApplicationCount = item.ApplicationGroups.SelectMany(x => x.Applications).Count().ToString(), Sessions = (item.ApplicationGroups.SelectMany(x => x.Applications)).Select(y => y.Id).ToString(), FirstUsedDate = dateCreated == new DateTime() ? "N/A" : dateCreated.ToShortDateString() + " " + dateCreated.ToShortTimeString(), ApplicationGroups = item.ApplicationGroups.Select(x => x.ToModel()).ToArray(), UniqueIdentifier = item.GetUniqueIdentifier(allInitiativeNames), }; return(response); }
public HttpResponseMessage Create(HttpRequestMessage request, InitiativeViewModel initiativeVM) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var initiative = Mapper.Map <InitiativeViewModel, Initiative>(initiativeVM); var userId = User.Identity.GetUserId(); var res = _initiativeService.Add(initiative, userId); response = res ? request.CreateResponse(HttpStatusCode.Created, new Initiative()) : request.CreateResponse(HttpStatusCode.BadRequest, new Initiative()); } return response; })); }
public ActivityAndChallengesResponse(InitiativeViewModel viewModel) : this(true, string.Empty, viewModel) { }
private ActivityAndChallengesResponse(bool success, string message, InitiativeViewModel activity) : base(success, message) { Activity = activity; }