Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        public void OnGet()
        {
            var SessionAddress = HttpContext.Session.GetString("SessionAddress");

            if (SessionAddress != null)
            {
                Address = JsonConvert.DeserializeObject <AddressBook.Models.Address>(SessionAddress);
            }
        }
Exemplo n.º 3
0
 public void EditAddress(Address address)
 {
     db.Entry(address).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 4
0
 public void CreateAddress(Address address)
 {
     address.Id = Guid.NewGuid();
     db.Address.Add(address);
     db.SaveChanges();
 }
Exemplo n.º 5
0
        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");
            }
        }