public ActionResult Create(string title,int city,string address,string pic,string start,string end,string contact,string phone,string sponsor,string context,string cost,string limited) { activity = new Activity() { Title=HtmlCommon.ClearHtml(title), CityId=city, Address=address, StartDate=DateTime.Parse(start), EndDate=DateTime.Parse(end), Contact=contact, Phone=phone, Sponsor=sponsor, Context=context, Cover=pic, Cost=cost, Limited=limited, VarDate=DateTime.Now }; using (club = new ClubEntities()) { club.Activities.Add(activity); if (club.SaveChanges() >= 0) { status = Status.success; hitStr = "活动添加成功!"; } else { hitStr = "添加失败,请稍后重试!"; } } ViewBag.StatusStr = HtmlCommon.GetHitStr(status,hitStr); return View("~/areas/bwum/views/activity/edit.cshtml",activity); }
public ActionResult Create() { activity = new Activity(); using (club = new ClubEntities()) { GetProvince(club); } return View("~/areas/bwum/views/activity/edit.cshtml",activity); }
public ActionResult Edit(int id,string title, int city, string address, string pic, string start, string end, string contact, string phone, string sponsor, string context, string cost, string limited){ using (club = new ClubEntities()) { activity = club.Activities.Where(a => a.Id == id).FirstOrDefault(); activity.Title = title; activity.CityId = city; activity.Address = address; activity.Cover = pic; activity.StartDate = Convert.ToDateTime(start.Length > 0 ?start: DateTime.Now.ToString()); activity.EndDate = Convert.ToDateTime(end.Length > 0 ? end:DateTime.Now.ToString() ); activity.Contact = contact; activity.Phone = phone; activity.Sponsor = sponsor; activity.Cost = cost; activity.Limited = limited; activity.Context = context; if (club.SaveChanges() >= 0){ ViewBag.Area = club.Areas.Where(a => a.Id == activity.CityId).FirstOrDefault(); status = Status.success; hitStr = "活动更新成功!"; } else{ hitStr = "更新失败,请稍后重试!"; } } ViewBag.StatusStr = HtmlCommon.GetHitStr(hitStr, status); return View("~/areas/bwum/views/activity/edit.cshtml", activity); }
public ActionResult Show(int? id) { tId = id ?? 0; using (club = new ClubEntities()) { activity = club.Activities.Where(a => a.Id == tId).FirstOrDefault(); if (activity == null) { return Redirect("/error/notfound"); } GetProvince(club); ViewBag.Area = club.Areas.Where(a => a.Id == activity.CityId).FirstOrDefault(); } return View("~/areas/bwum/views/activity/edit.cshtml", activity); }