public ActionResult Create(PropertyOwner propertyowner)
        {
            if (ModelState.IsValid)
            {
                db.PropertyOwners.Add(propertyowner);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(propertyowner);
        }
        public ActionResult Create(PropertyOwner propertyowner)
        {
            propertyowner.WhenCreated = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.PropertyOwners.Add(propertyowner);
                db.SaveChanges();
                return RedirectToAction("Edit", new { id = propertyowner.PropertyOwnerID });    
            }

            return View(propertyowner);
        }
        public ActionResult Edit(PropertyOwner propertyowner)
        {
            propertyowner.WhenCreated = DateTime.Now;
            propertyowner.WhenUpdated =
                db.PropertyOwners.Where(x => x.PropertyOwnerID == propertyowner.PropertyOwnerID).First().WhenUpdated;


            if (ModelState.IsValid)
            {
                using (var _db = new PortugalVillasContext())
                {
                    _db.PropertyOwners.Attach(propertyowner);
                    _db.Entry(propertyowner).State = EntityState.Modified;
                    _db.SaveChanges();
                    return RedirectToAction("Edit", new { id = propertyowner.PropertyOwnerID });    
                }
                
                
            }
            return View(propertyowner);
        }
 public ActionResult Edit(PropertyOwner propertyowner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(propertyowner).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(propertyowner);
 }