public ActionResult Create(FormCollection collection) { Session.Add("ActiveClass", "ChuShopCreate"); if (Session["ID"] != null) { var chuShop = new ChuShop(); var sp = QLSRes.GetShopByAccount(int.Parse(Session["ID"].ToString())); if (sp != null) { try { if (TryUpdateModel(chuShop)) { // TODO: Add insert logic here IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true); String datetime = collection["NgaySinh"]; DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault); chuShop.NgaySinh = dt; chuShop.QLSHOP_ID = sp.QLSHOP_ID; chuShop.NgayCapNhat = DateTime.Now; chuShop.NgayTao = DateTime.Now; CSRes.Add(chuShop); CSRes.Save(); return RedirectToAction("Details", new { id = chuShop.ChuShopID }); } else { ViewData["TinhThanh"] = CMRes.FindAllTinhThanh(); return View(chuShop); } } catch { ViewData["TinhThanh"] = CMRes.FindAllTinhThanh(); return View(chuShop); } } else { ModelState.AddModelError("", "Bạn chưa có Shop"); return View("Error"); } } else { Session.Add("UrlRedirect", Url.AbsoluteAction("Create", "ChuShop")); return RedirectToAction("LogOn", "Account"); } }
public void Delete(ChuShop dm) { en.DeleteObject(dm); }
public void Add(ChuShop dm) { en.AddObject("ChuShop", dm); }
public ActionResult getDetailsPublic(int id) { var m = CSRes.GetChuShopByShopID(id); if (m == null) m = new ChuShop(); return PartialView("getDetailsPublic", m); }