public FileStreamResult GetListPerson() { StringBuilder sb = new StringBuilder(); foreach (var personItem in PersonHelper.PersonModelList) { var awardsIds = PersonLinkAwardHelper.GetPersonLinkAwardList() .Where(_ => _.PersonModelData.Id == personItem.Id) .Select(_ => _.AwardModelData.Id) .ToList(); if (awardsIds.Any()) { foreach (var itemawardsId in awardsIds) { sb.Append(string.Format("{0} {1} \r\n", personItem.Name, AwardHelper.GetAwardById(itemawardsId).Title)); } } else { sb.Append(string.Format("{0} Наград нет \r\n", personItem.Name)); } } var fs = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString())); return(File(fs, "text/csv")); }
public ActionResult IndexByUser(string userName) { var res = PersonLinkAwardHelper.GetPersonLinkAwardList() .Where(_ => _.PersonModelData.Name == userName) .Select(_ => _.AwardModelData) .ToList(); return(View("Index", res)); }
public ActionResult CheckAwardDuplicate(PersonLinkAwardModel personLinkAwardModel) { var currentList = PersonLinkAwardHelper.GetPersonLinkAwardList(); if (currentList.Any(_ => _.AwardModelData.Id == personLinkAwardModel.AwardId && _.PersonModelData.Id == personLinkAwardModel.PersonId)) { return(Json(false, JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public ActionResult AttachedAward(PersonLinkAwardModel model) { if (!ModelState.IsValid) { return(View()); } PersonLinkAwardHelper.AddAwardToPerson(model); return(RedirectToAction("Index")); }
public ActionResult Delete(Guid personId, Guid awardId) { PersonLinkAwardHelper.DeeteAttachedAward(personId, awardId); return(RedirectToAction("Index")); }
public ActionResult NewAttachAward() { ViewBag.PersonModelListItem = PersonLinkAwardHelper.PersonModelListItem(); ViewBag.AwardModelListItem = PersonLinkAwardHelper.AwardModelListItem(); return(View(PersonLinkAwardHelper.NewAttachAward())); }
public ActionResult Index() { return(View(PersonLinkAwardHelper.GetPersonLinkAwardList())); }