public ActionResult Edit(int id, BoSuuTap bosuutap) { bosuutap = (from s in data.BoSuuTaps where s.MaBST == id select s).FirstOrDefault(); UpdateModel(bosuutap); if (String.IsNullOrEmpty(bosuutap.TenBST)) { ViewBag.ThongBao = "Chưa nhập"; } else { try { data.SubmitChanges(); ViewBag.ThongBao = "SUCCESS"; } catch (Exception e) { Console.WriteLine(e); ViewBag.ThongBao = "Lỗi nhập size(vd: xxl... không lớn hơn 3 chữ cái)"; } } return(View()); }
public ActionResult Delete(int id, BoSuuTap bosuutaps) { bosuutaps = (from s in data.BoSuuTaps where s.MaBST == id select s).FirstOrDefault(); SanPham sanpham = (from s in data.SanPhams where s.MaBST == id select s).FirstOrDefault(); if (sanpham != null) { return(HttpNotFound()); } else { try { data.BoSuuTaps.DeleteOnSubmit(bosuutaps); data.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } }
public ActionResult Create(BoSuuTap bosuutaps) { data.BoSuuTaps.InsertOnSubmit(bosuutaps); if (String.IsNullOrEmpty(bosuutaps.TenBST)) { ViewBag.ThongBao = "Chưa nhập"; } else { try { data.SubmitChanges(); ViewBag.ThongBao = "SUCCESS"; } catch (Exception e) { Console.WriteLine(e); ViewBag.ThongBao = "Lỗi nhập size(vd: xxl... không lớn hơn 3 chữ cái)"; } } return(this.Create()); }