예제 #1
0
        public ActionResult addProducer(ProducerInfo producerinfo)
        {
            if (!isAdmin())
            {
                return(RedirectToAction("LogIn", "Main"));
            }

            if (ModelState.IsValid)
            {
                Customer c    = (Customer)Session["loggedInUser"];
                Producer prod = new Producer();
                prod.id   = producerinfo.prodId;
                prod.name = producerinfo.prodName;
                bool OK = _categoryBLL.AddProducer(prod, c.id);
                if (OK)
                {
                    return(Json(new { success = true, message = prod.name + " ble lagt til.", redirect = "/Category/ListProducers?item_desc" }));
                }
                return(Json(new { success = false, message = "noe gikk galt, prøv igjen senere." }));
            }
            return(Json(new { success = false, message = "Feil i validering" }));
        }