示例#1
0
        public ActionResult Create(Shoferi shof)
        {
            if (Session["UserID"] != null)
            {
                ShoferiBusiness shb = new ShoferiBusiness();
                if (ModelState.IsValid)

                {
                    if (shb.Shoferet.Any(ac => ac.perdoruesi.Equals(shof.perdoruesi)))
                    {
                        //error
                        ModelState.AddModelError(string.Empty, "Egziston nje shofer me kete emer !");
                        return(View());
                    }
                    else
                    {
                        shb.shto(shof);
                        return(RedirectToAction("Index", "Shoferi"));
                    }
                }
                else
                {
                    Utility utility = new Utility();
                    ViewBag.IdDispecher = new SelectList(utility.GetDispecher(), "id", "emri");
                    ViewBag.IdKlienti   = new SelectList(utility.GetKlient(), "id", "emri");
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Index", "Hyrje"));
            }
        }