public ActionResult Grant(GroupRoles gr) { string msg = ""; // 1. Gán // 2. Hủy // Kiểm tra quyền đã có hay chưa if (_groupRole.GetAll().Any(x => x.GroupId == gr.GroupId && x.BusinessId == gr.BusinessId && x.RoleId == gr.RoleId)) { // Quyền đã tồn tại => Hủy var _gr = _groupRole.SingleBy(x => x.GroupId == gr.GroupId && x.BusinessId == gr.BusinessId && x.RoleId == gr.RoleId); // Hủy quyền (xóa) _groupRole.Remove(_gr); msg = "Drop Role Successfully!"; } else { // Quyền chưa tồn tại => Gán quyền _groupRole.Add(gr); msg = "Assign Role Successfully!"; } return(Json(new { StatusCode = 200, Message = msg }, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(AttributeType atty) { if (ModelState.IsValid) { if (_atty.Add(atty)) { return(RedirectToAction("Index")); } return(View()); } return(View()); }
public ActionResult Create(Supplier sup) { if (ModelState.IsValid) { if (_sup.Add(sup)) { return(RedirectToAction("Index")); } return(View()); } return(View()); }
public ActionResult Create(Category c) { if (ModelState.IsValid) { if (_cat.Add(c)) { return(RedirectToAction("Index")); } return(View()); } return(View()); }
public ActionResult Create(Note n) { if (ModelState.IsValid) { if (_note.Add(n)) { return(RedirectToAction("Index")); } return(View()); } return(View()); }
public ActionResult Create(Attributes attr) { ViewBag.TypeId = new SelectList(_atty.GetAll(), "AttrTypeId", "TypeName"); if (ModelState.IsValid) { if (_attr.Add(attr)) { return(RedirectToAction("Index")); } return(View()); } return(View()); }
public ActionResult Create(Post p) { if (ModelState.IsValid) { if (_pos.Add(p)) { return(RedirectToAction("Index")); } else { return(View()); } } return(View()); }
public ActionResult Create(User attr) { ViewBag.GroupId = new SelectList(_gr.GetAll(), "GroupId", "GroupName"); if (ModelState.IsValid) { if (_us.Add(attr)) { return(RedirectToAction("Index")); } return(View()); } return(View()); }
public ActionResult Create(Banner b) { ViewBag.NoteId = new SelectList(_note.GetBy(x => x.Type == 1), "Id", "AttrName"); if (ModelState.IsValid) { if (_ban.Add(b)) { return(RedirectToAction("Index")); } else { return(View()); } } return(View()); }
public ActionResult Create(UserRegisterModel u) { if (ModelState.IsValid) { User us = new User(); us.UserName = u.UserName; us.Password = u.Password; us.Email = u.Email; us.Address = u.Address; us.Password = u.Password; us.FullName = u.FullName; us.Status = true; us.GroupId = 2; _u.Add(us); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Update() { var controllers = rfl.GetAllController("Project.Net.Areas.Admin.Controllers"); foreach (Type item in controllers) { var _ctrlName = item.Name.Replace("Controller", ""); // Kiểm tra nghiệp vụ đã tồn tại hay chưa if (!_business.GetAll().Any(x => x.BusinessId == _ctrlName)) // Nếu chưa tồn tại { Business b = new Business() { BusinessId = _ctrlName, BusinessName = "Đang cập nhật...." }; _business.Add(b); } } return(RedirectToAction("Index")); }
public ActionResult Create(Product p, IEnumerable <HttpPostedFileBase> file) { ViewBag.CategoryId = new SelectList(_cat.GetAll(), "CategoryId", "CategoryName"); ViewBag.SupplierId = new SelectList(_sup.GetAll(), "SupplierId", "SupplierName"); ViewBag.AttrType = _attr.GetAll().AsQueryable().Include(x => x.Attributes).AsEnumerable(); ViewBag.proNote = _note.GetBy(x => x.Type == 2).AsEnumerable(); if (p.ProductAttrs != null) { p.ProductAttrs.ToList().ForEach(x => x.ProductId = p.ProductId); } if (p.ProductNotes != null) { p.ProductNotes.ToList().ForEach(x => x.ProductId = p.ProductId); } if (ModelState.IsValid) { if (_product.Add(p)) { return(RedirectToAction("Index")); } return(View()); } return(View()); }
public ActionResult Payment(Order order) { var price = 0; order.Created = DateTime.Now; order.Status = 1; List <ItemCart> lst = new List <ItemCart>(); lst = Session["cart"] as List <ItemCart>; List <OrderDetails> orderDetails = new List <OrderDetails>(); foreach (var item in lst) { //if (item.Product.SalePrice != null) //{ // price = (int)item.Product.SalePrice; //} //else //{ // price = (int)item.Product.Price; //} OrderDetails od = new OrderDetails() { ProductId = item.Product.ProductId, Attributes = item.Attributes, Quantity = item.Quantity, Price = item.price, }; orderDetails.Add(od); } order.OrderDetails = orderDetails; if (!_orders.Add(order)) { return(View()); } string _header = System.IO.File.ReadAllText(Server.MapPath(@"~/App_Data/header_order.txt")); string _footer = System.IO.File.ReadAllText(Server.MapPath(@"~/App_Data/footer_order.txt")); #region Thông tin người nhận string _main = String.Format(@"<h2 class='title'>ĐƠN HÀNG ONETECH{5}</h2> <p> <b>Họ tên người nhận</b> <span>{0}</span> </p> <p> <b>Email</b> <span>{1}</span> </p> <p> <b>SĐT</b> <span>{2}</span> </p> <p> <b>Địa chỉ</b> <span>{3}</span> </p> <p> <b>Ngày mua</b> <span>{4:dd/MM/yyyy | HH:mm:ss}</span> </p>" , order.FullName, order.Email, order.Phone, order.Address, order.Created, order.OrderId); #endregion #region Sản phẩm mua double total = 0; _main += @"<table class='table text-center'> <thead> <tr> <th>Sản phẩm</th> <th>Đơn giá</th> <th>Số lượng</th> <th>Thành tiền</th> </tr> </thead> <tbody>" ; foreach (var item in lst) { _main += @"<tr>"; _main += String.Format(@"<td>{0}</td>", item.Product.ProductName); _main += String.Format(@"<td>${0:#,##}</td>", price); _main += String.Format(@"<td>{0}</td>", item.Quantity); _main += String.Format(@"<td>${0:#,##}</td>", item.price * item.Quantity); _main += @"</tr>"; total += item.price * item.Quantity; } _main += String.Format(@"<tr> <th colspan='3' style='text-align: right;margin-right:60px;'>Tổng tiền</th> <th>${0:#,##}</th> </tr> </tbody> </table>" , total); #endregion Helpers.SendEmail(order.Email, "*****@*****.**", "quantriwebbkap", "[BKAPSHOP]_THÔNG TIN ĐƠN HÀNG", _header + _main + _footer); Session.Remove("cart"); return(RedirectToAction("Index", "Home")); }