/// <summary> /// Edit the entity by passing in the form collection so it maps the /// html fields to the entity properites. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="id"></param> /// <param name="collection"></param> /// <param name="fetcher"></param> /// <returns></returns> public override ActionResult Edit(Profile updated) { DashboardLayout(true); EntityActionResult result = null; try { result = _helper.Edit(updated, (original) => { // Copy back the original values. updated.UserId = original.UserId; updated.UserName = original.UserName; ProfileHelper.ChangeEmail(updated, original); if (!updated.Errors.HasAny) { ProfileHelper.ApplyProfileImage(updated); } }); } catch { result = new EntityActionResult(false, "Error while updating profile", item: updated, isAuthorized: true, isAvailable: true); } return(BuildRedirectResult(result, successAction: _viewSettings.ActionForCreationSuccess, routeValues: new { id = updated.Id }, viewLocationForErrors: _viewSettings.PageLocationForEdit, viewActionForErrors: "Edit")); }
public EntityActionResult GetReady(Matcher matcher) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); matcher.Status = MatcherStatus.Ready; if (matcher.Inventories.Any()) { var validInventory = _inventoryService.ValidateRange(matcher.Inventories); if (!validInventory.Where(vi => !vi.Success).Any()) { errors.Add("Invalid inventory."); } } result = _matcherService.Update(matcher); if (!_matcherService.Save()) { errors.Add("Something wint wrong saving."); } if (errors.Any()) { result.ErrorCode = 500; result.Success = false; result.Messages = errors; } return(result); }
public EntityActionResult DismisInvitation(Guid matchRequestId) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); var req = _matchRequestService.Find(matchRequestId); if (req != null) { req.MatchRequestStatus = MatchRequestStatus.No; result = _matchRequestService.Update(req); } else { errors.Add("This request does not exists"); } if (!_matchRequestService.Save()) { errors.Add("Something wint wrong saving."); } if (errors.Any()) { result.ErrorCode = 500; result.Success = false; result.Messages = errors; } return(result); }
public EntityActionResult StartMatch(Guid matchId) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); throw new NotImplementedException(); }
public EntityActionResult AceptInvitation(Guid matchRequestId) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); var req = _matchRequestService.Find(matchRequestId, "PlayerId, PlayerId.Characters"); req.MatchRequestStatus = MatchRequestStatus.Yes; if (req.MatchId != null && req.PlayerId != null && req.Player.Characters.Any()) { Matcher matcher = new Matcher { Status = MatcherStatus.Waitting, CharacterId = req.Player.Characters.FirstOrDefault().Id, MatchId = (Guid)req.MatchId }; result = _matcherService.Add(matcher); } else { errors.Add("You must have a character to acept."); } if (!_matcherService.Save()) { errors.Add("Something wint wrong saving."); } if (errors.Any()) { result.ErrorCode = 500; result.Success = false; result.Messages = errors; } return(result); }
public EntityActionResult SelectCharacter(Guid characterId, Guid matcherId) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); throw new NotImplementedException(); }
public EntityActionResult QuitPlayer(Guid matcherId) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); var matcher = _matcherService.Find(matcherId); if (matcher != null) { _matcherService.Delete(matcher); result.Success = true; } else { errors.Add("This player does not exists on this match"); } if (!_matcherService.Save()) { errors.Add("Something wint wrong saving."); } if (errors.Any()) { result.ErrorCode = 500; result.Success = false; result.Messages = errors; } return(result); }
public EntityActionResult InvitePlayer(Guid playerId, Guid matchId) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); if (_playerService.FindBy(p => p.Id == playerId).Any() && _matchService.FindBy(p => p.Id == matchId).Any()) { result = _matchRequestService.Add(new MatchRequest { MatchId = matchId, PlayerId = playerId, MatchRequestStatus = MatchRequestStatus.Pending, }); } else { errors.Add("Player or Match invalid"); } if (!_matchRequestService.Save()) { errors.Add("Something wint wrong saving."); } if (errors.Any()) { result.ErrorCode = 500; result.Success = false; result.Messages = errors; } return(result); }
/// <summary> /// Find posts by category /// </summary> /// <param name="year"></param> /// <param name="month"></param> /// <returns></returns> public ActionResult Category(int id) { Tuple2 <PagedList <Post>, Category> result = CategoryHelper.FindCategoryAndItems <Post>(id, 1, 10, "CategoryId"); SetPageTitle(result.Second == null ? "" : result.Second.Name); var entityResult = new EntityActionResult(true, "", null, result.First, true, true); var actionResult = BuildActionResult(entityResult, "Pages/List"); return(actionResult); }
private ActionResult ShowByEntity(Page page) { if (page == null || !page.IsPublic) { return(View(PageLocationForNotFound)); } var result = new EntityActionResult(true, item: page, isAuthorized: true, isAvailable: true); HandlePageTitle(result); return(BuildActionResult(result, _viewSettings.PageLocationForDetails)); }
public override ActionResult Delete(int id) { EntityActionResult result = _helper.Delete(id); var message = result.Success ? _modelname + " has been deleted" : result.Message; if (!result.Success) { return(Json(new { Success = result.Success, Message = message }, JsonRequestBehavior.AllowGet)); } var items = MenuEntry.Find(Query <MenuEntry> .New().Where(m => m.RefId).Is(id)); if (items != null && items.Count > 0) { var item = items[0]; MenuEntry.Delete(item); } return(Json(new { Success = result.Success, Message = message }, JsonRequestBehavior.AllowGet)); }