public IActionResult Create(string Title) { var contest = new Contest { Begin = new DateTime(2099,1,1), End = new DateTime(2099,1,2), Title = Title }; DB.Contests.Add(contest); DB.SaveChanges(); return RedirectToAction("Edit", "Contest", new { id = contest.Id }); }
public IActionResult Edit(string id, Contest Model) { var ret = DB.Contests .Where(x => x.Id == id) .SingleOrDefault(); if (ret == null) return Prompt(x => { x.Title = "资源没有找到"; x.Details = "您请求的资源没有找到,请返回重试!"; x.StatusCode = 404; }); ret.Description = Model.Description; ret.Begin = Model.Begin; ret.End = Model.End; ret.Title = Model.Title; DB.SaveChanges(); return Prompt(x => { x.Title = "修改成功"; x.Details = "比赛信息已经修改成功!"; }); }