Ejemplo n.º 1
0
        public async Task <IActionResult> ListByCompetition(int id, string s, int?award = null)
        {
            List <Models.Crew> crews;

            Models.Competition comp = await _context.Competitions.Include(c => c.TimingPoints).FirstOrDefaultAsync(c => c.CompetitionId == id);

            if (comp is null)
            {
                return(NotFound());
            }

            if (award == null)
            {
                crews = await _context.Crews.Include(c => c.Results).Where(c => c.CompetitionId == id).ToListAsync();
            }
            else
            {
                Models.Award dbAward = await _context.Awards.Include("Crews.Crew.Results")
                                       .FirstOrDefaultAsync(a => a.AwardId == award);

                crews = dbAward.Crews.Select(x => x.Crew).ToList();
            }

            List <Crew> results = ResultsHelper.BuildCrewsList(_mapper, comp, crews);

            if (String.IsNullOrEmpty(s))
            {
                return(Ok(results));
            }
            else
            {
                return(Ok(results.Where(x => x.Name.ToUpper(CultureInfo.CurrentCulture)
                                        .Contains(s.ToUpper(CultureInfo.CurrentCulture), StringComparison.CurrentCulture)).ToList()));
            }
        }
 public PartialViewResult RemoveAward(int id)
 {
     var award = new Models.Award() { ID = id };
     var tblAward = new TblAward();
     tblAward.Delete(award);
     return PartialView("_PartialAward", tblAward.GetAll());
 }
 public PartialViewResult InsertAward(string desc)
 {
     var award = new Models.Award() { Description = HttpUtility.UrlDecode(desc) };
     var tblAward = new TblAward();
     tblAward.Add(award);
     return PartialView("_PartialAward", tblAward.GetAll());
 }
 public PartialViewResult UpdateAward(int id, string desc)
 {
     var award = new Models.Award() { ID = id, Description = HttpUtility.UrlDecode(desc) };
     var tblAward = new TblAward();
     tblAward.Update(award);
     return PartialView("_PartialAward", tblAward.GetAll());
 }
Ejemplo n.º 5
0
 public ActionResult AwardManager_Submit(Models.Award award)
 {
     if (award.ID == 0 && Config.Helper.Count <Award>("where awardname=@0", award.AwardName) > 0)
     {
         return(Error("相同奖项名称已经存在"));
     }
     else
     {
         var projectids = Request.Form["projectids"];
         var expertids  = Request.Form["expertids"];
         Award.Save(award, expertids, projectids);
         return(SuccessCallback("保存成功", "location.href='/Manager/AwardManager_List'"));
     }
 }