Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "farmId,name,address,town,county,provinceCode,postalCode,homePhone,cellPhone,directions,dateJoined,lastContactDate")] farm farm)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.farms.Add(farm);
                    db.SaveChanges();
                    TempData["message"]     = "Farm created successfully";
                    TempData["messageType"] = "success";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                TempData["message"]     = "Error creating farm: " + ex.GetBaseException().Message;
                TempData["messageType"] = "danger";
            }

            return(View(farm));
        }