public void Delete(int Id, Customer cus) { Customer customerToDelete = (from cust in _dataContext.Customers.OfType<Customer>() .Include("Addresses") .Include("Telephones") .Include("ElectronicMails") .Include("Orders") where cust.Id == Id select cust).Single(); List<Address> addressesToDelete = customerToDelete.Addresses.ToList(); List<Telephone> telephonesToDelete = customerToDelete.Telephones.ToList(); List<ElectronicMail> emailsToDelete = customerToDelete.ElectronicMails.ToList(); List<Order> ordersTodelete = customerToDelete.Orders.ToList(); foreach (Address r in addressesToDelete) { _dataContext.DeleteObject(r); } foreach (Telephone r in telephonesToDelete) { _dataContext.DeleteObject(r); } foreach (ElectronicMail r in emailsToDelete) { _dataContext.DeleteObject(r); } foreach (Order r in ordersTodelete) { _dataContext.DeleteObject(r); } _dataContext.DeleteObject(customerToDelete); _dataContext.SaveChanges(); }
public void Edit(int id, Customer entity) { Customer entityToEdit = (from cust in _dataContext.Customers where cust.Id == id select cust).FirstOrDefault(); entityToEdit.FirstName = entity.FirstName; entityToEdit.LastName = entity.LastName; entityToEdit.MI = entity.MI; entityToEdit.ModifiedDate = DateTime.Now; _dataContext.SaveChanges(); }
public void Add(Customer customer) { var cust = new Customer { Id = PrimaryKeyUtil.RandomNumber(1, 100903), FirstName = customer.FirstName, LastName = customer.LastName, MI = customer.MI, ModifiedDate = DateTime.Now }; _dataContext.Customers.AddObject(cust); _dataContext.SaveChanges(); }
public ActionResult Create(Customer customer) { try { _customerService.Add(customer); var custToDisplay = new CustomerViewModel { Id = customer.Id, FirstName = customer.FirstName, MI = customer.MI, LastName = customer.LastName, ModifiedDate = customer.ModifiedDate }; return RedirectToAction("Index", custToDisplay); } catch { return View(); } }
public ActionResult Delete(int Id, Customer customer) { try { Customer customerToDelete = _customerService.Get(Id); _customerService.Delete(Id, customerToDelete); var custToDisplay = new CustomerViewModel { Id = customer.Id, FirstName = customerToDelete.FirstName, MI = customerToDelete.MI, LastName = customerToDelete.LastName, ModifiedDate = customerToDelete.ModifiedDate }; return RedirectToAction("Index", custToDisplay); } catch { return View(); } }
public void Edit(int id, Customer customer) { _customerRepository.Edit(id, customer); }
public void Delete(int Id, Customer customer) { _customerRepository.Delete(Id, customer); }
public void Add(Customer customer) { _customerRepository.Add(customer); }
/// <summary> /// Create a new Customer object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param> /// <param name="customerName">Initial value of the CustomerName property.</param> public static Customer CreateCustomer(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.DateTime modifiedDate, global::System.String customerName) { Customer customer = new Customer(); customer.Id = id; customer.FirstName = firstName; customer.LastName = lastName; customer.ModifiedDate = modifiedDate; customer.CustomerName = customerName; return customer; }
/// <summary> /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCustomers(Customer customer) { base.AddObject("Customers", customer); }