Пример #1
0
        public ActionResult Edit(Staff_info staff)
        {
            if (ModelState.IsValid)
            {

                try
                {

                    System.Collections.Specialized.NameValueCollection postedValues = Request.Form;
                    Address addre = new Address();
                    Staff_info oldStaff = (Staff_info)Session["staff"];
                    staff.Create_date = oldStaff.Create_date;
                    staff.Address_id = oldStaff.Address_id;
                    staff.Staff_id = oldStaff.Staff_id;
                    staff.Address = oldStaff.Address;
                    staff.Address.City = postedValues["Address.City"];
                    staff.Address.Country = postedValues["Address.Country"];
                    staff.Address.House_number = postedValues["Address.House_number"];
                    staff.Address.Postcode = postedValues["Address.Postcode"];
                    staff.Address.Province = postedValues["Address.Province"];
                    staff.Address.Street_name = postedValues["Address.Street_name"];
                    staff.Address.Street_number = postedValues["Address.Street_number"];
                    repo.UpdateAddress(staff.Address);
                    repo.UpdateStaffInfo(staff);
                    repo.Save();
                    return RedirectToAction("Index");
                }
                catch (Exception ex)
                {
                    //get the innermost exception
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    ModelState.AddModelError("", "error on create: " + ex.GetBaseException().Message);
                }
            }
            //ViewBag.Big_Image_id = new SelectList(db.Image_info, "Image_id", "Path", menu.Big_Image_id);
            //ViewBag.Small_Image_id = new SelectList(db.Image_info, "Image_id", "Path", menu.Small_Image_id);
            return View(staff);
        }
Пример #2
0
 public void InsertAddress(Address address)
 {
     int id = context.Database.SqlQuery<int>("GetAddressMaxID").Single() + 1;
     context.Addresses.Add(address);
 }
Пример #3
0
 public void UpdateAddress(Address address)
 {
     context.Entry(address).State = EntityState.Modified;
 }
Пример #4
0
        public ActionResult Edit(Customer_Info customer_info)
        {
            if (ModelState.IsValid)
            {
                try
                {

                    System.Collections.Specialized.NameValueCollection postedValues = Request.Form;
                    Address addre = new Address();
                    Customer_Info oldCustomer = (Customer_Info)Session["customer"];
                    customer_info.Address_id = oldCustomer.Address_id;
                    customer_info.Customer_id = oldCustomer.Customer_id;
                    customer_info.Address = oldCustomer.Address;
                    customer_info.Address.City = postedValues["Address.City"];
                    customer_info.Address.Country = postedValues["Address.Country"];
                    customer_info.Address.House_number = postedValues["Address.House_number"];
                    customer_info.Address.Postcode = postedValues["Address.Postcode"];
                    customer_info.Address.Province = postedValues["Address.Province"];
                    customer_info.Address.Street_name = postedValues["Address.Street_name"];
                    customer_info.Address.Street_number = postedValues["Address.Street_number"];
                    repo.UpdateAddress(customer_info.Address);
                    repo.UpdateCustomerInfo(customer_info);
                    repo.Save();
                    return RedirectToAction("Index");
                }
                catch (Exception ex)
                {
                    //get the innermost exception
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    ModelState.AddModelError("", "error on create: " + ex.GetBaseException().Message);
                }
            }
            return View(customer_info);
        }