public ActionResult Create(Address address)
        {
            try
            {
                if (ModelState.IsValid)
                {

                    log.Debug("Start create address");
                    address.PeopleInfo_PeopleId = (Guid) TempData["PeopleId"];
                    dbManager.CreateAddress(address);

                    log.Debug("Save: Ok");
                    return RedirectToAction("Details", "Home", new {id = (Guid) TempData["PeopleId"]});
                }

                ModelState.AddModelError("", "Model error");
                return View(address);
            }
            catch (Exception exception)
            {
                log.Error(string.Format("Save: Fail;   Exception message:{0}", exception.Message));

                return RedirectToAction("Error500", "Error");
            }
        }
Esempio n. 2
0
        public void OnGet()
        {
            var SessionAddress = HttpContext.Session.GetString("SessionAddress");

            if (SessionAddress != null)
            {
                Address = JsonConvert.DeserializeObject <AddressBook.Models.Address>(SessionAddress);
            }
        }
Esempio n. 3
0
 public void EditAddress(Address address)
 {
     db.Entry(address).State = EntityState.Modified;
     db.SaveChanges();
 }
Esempio n. 4
0
 public void CreateAddress(Address address)
 {
     address.Id = Guid.NewGuid();
     db.Address.Add(address);
     db.SaveChanges();
 }
        public ActionResult Edit(Address address)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    log.Debug("Start edit");
                    dbManager.EditAddress(address);

                    log.Debug("Edit: Ok");
                    return RedirectToAction("Details", "Home", new {id = address.PeopleInfo_PeopleId});
                }
                ModelState.AddModelError("", "Model error");
                return View(address);
            }
            catch (Exception exception)
            {
                log.Error(string.Format("Edit Post method: Fail;   Exception message:{0}", exception.Message));
                return RedirectToAction("Error500", "Error");
            }
        }