示例#1
0
        public ActionResult Create(LocationViewModel location)
        {
            if (ModelState.IsValid)
            {
                var dept = new Location
                {
                    Id           = location.Id,
                    LocationName = location.LocationName,
                    Date         = location.Date,
                    Description  = location.Description
                };
                _locationmanager.Add(dept);
                _locationmanager.GetAll().ToList();
                _locationmanager.SaveChanges();
                TempData["Success"] = "Added Successfully!";

                //return Json(new { success = true, messsage = "Saved Successfully" }, JsonRequestBehavior.AllowGet);
                //TempData["message"] = string.Format("{0} has been saved.", location);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(location));
            }


            //return View();
        }