Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ContactId,CustId,Home1,Home2,Home3,Cell1,Cell2,Cell3,Work1,Work2,Work3,Email,LastUpdated,CheckBox")] Contact contact, bool checkBox)
        {
            if (ModelState.IsValid)
            {
                Contact NewContact = new Contact();
                NewContact.ContactId   = contact.ContactId;
                NewContact.CustId      = contact.CustId;
                NewContact.Home1       = contact.Home1;
                NewContact.Home2       = contact.Home2;
                NewContact.Home3       = contact.Home3;
                NewContact.Cell1       = contact.Cell1;
                NewContact.Cell2       = contact.Cell2;
                NewContact.Cell3       = contact.Cell3;
                NewContact.Work1       = contact.Work1;
                NewContact.Work2       = contact.Work2;
                NewContact.Work3       = contact.Work3;
                NewContact.Email       = contact.Email;
                NewContact.CheckBox    = contact.CheckBox;
                NewContact.LastUpdated = contact.LastUpdated = DateTime.Now;
                _context.Contact.Add(NewContact);
                await _context.SaveChangesAsync();

                if (NewContact.CheckBox == true)
                {
                    return(RedirectToAction("Create", "Dependents", new { CustId = NewContact.CustId }));
                }
                else
                {
                    return(RedirectToAction("Create", "Deposits", new { CustId = NewContact.CustId }));
                }
            }

            ViewData["CustId"] = new SelectList(_context.Customer, "CustId", "CustId", contact.CustId);
            return(View(contact));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(Dependent dependent)
        {
            if (ModelState.IsValid)
            {
                Dependent NewDependent = new Dependent();
                NewDependent.DepId       = dependent.DepId;
                NewDependent.CustId      = dependent.CustId;
                NewDependent.FirstName   = dependent.FirstName;
                NewDependent.LastName    = dependent.LastName;
                NewDependent.Ssn1        = dependent.Ssn1;
                NewDependent.Ssn2        = dependent.Ssn2;
                NewDependent.Ssn3        = dependent.Ssn3;
                NewDependent.LastUpdated = dependent.LastUpdated = DateTime.Now;
                NewDependent.CheckBox    = dependent.CheckBox;
                _context.Dependent.Add(NewDependent);
                await _context.SaveChangesAsync();

                if (NewDependent.CheckBox == true)
                {
                    return(RedirectToAction("Create", "Dependents", new { CustId = NewDependent.CustId }));
                }
                else
                {
                    return(RedirectToAction("Create", "Deposits", new { CustId = NewDependent.CustId }));
                }
            }

            ViewData["CustId"] = new SelectList(_context.Customer, "CustId", "CustId", dependent.CustId);
            return(View(dependent));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(Deposit deposit)
        {
            if (ModelState.IsValid)
            {
                Deposit NewDeposit = new Deposit();
                NewDeposit.CustId      = deposit.CustId;
                NewDeposit.Routing     = deposit.Routing;
                NewDeposit.Account     = deposit.Account;
                NewDeposit.LastUpdated = deposit.LastUpdated = DateTime.Now;
                _context.Deposit.Add(NewDeposit);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Appointments", new { CustId = NewDeposit.CustId }));
            }

            ViewData["CustId"] = new SelectList(_context.Customer, "CustId", "CustId", deposit.CustId);
            return(View(deposit));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("CustId,LastAppt,NextAppt,LastUpdated")] Appointment appointment)
        {
            if (ModelState.IsValid)
            {
                Appointment NewAppointment = new Appointment();
                NewAppointment.CustId      = appointment.CustId;
                NewAppointment.LastAppt    = appointment.LastAppt;
                NewAppointment.NextAppt    = appointment.NextAppt;
                NewAppointment.LastUpdated = appointment.LastUpdated = DateTime.Now;
                _context.Appointment.Add(NewAppointment);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Customers"));
            }

            ViewData["CustId"] = new SelectList(_context.Customer, "CustId", "CustId", appointment.CustId);
            return(View(appointment));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("AddressId,CustId,Address1,Address2,City,State,ZipCode,LastUpdated")] Address address)
        {
            if (ModelState.IsValid)
            {
                Address NewAddress = new Address();
                NewAddress.AddressId   = address.AddressId;
                NewAddress.CustId      = address.CustId;
                NewAddress.Address1    = address.Address1;
                NewAddress.Address2    = address.Address2;
                NewAddress.City        = address.City;
                NewAddress.State       = address.State;
                NewAddress.ZipCode     = address.ZipCode;
                NewAddress.LastUpdated = address.LastUpdated = DateTime.Now;
                _context.Address.Add(NewAddress);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Contacts", new { CustId = NewAddress.CustId }));
            }

            //ViewData["CustId"] = new SelectList(_context.Customer, "CustId", "CustId", address.CustId);
            return(View(address));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("CustId,FirstName,LastName,Ssn1,Ssn2,Ssn3,LastUpdated")] Customer customer, Address address)
        {
            if (ModelState.IsValid)
            {
                Customer NewCustomer = new Customer();
                //NewCustomer.CustId = customer.CustId;
                NewCustomer.FirstName   = customer.FirstName;
                NewCustomer.LastName    = customer.LastName;
                NewCustomer.Ssn1        = customer.Ssn1;
                NewCustomer.Ssn2        = customer.Ssn2;
                NewCustomer.Ssn3        = customer.Ssn3;
                NewCustomer.LastUpdated = customer.LastUpdated = DateTime.Now;
                _context.Customer.Add(NewCustomer);
                await _context.SaveChangesAsync();

                NewCustomer.CustId = _context.Customer.Max(c => c.CustId);
                return(RedirectToAction("Create", "Addresses", new { CustId = NewCustomer.CustId }));
            }


            return(View(customer));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var customer = await _context.Customer.FindAsync(id);

            _context.Customer.Remove(customer);
            var address = await _context.Address.FindAsync(id);

            _context.Address.Remove(address);
            var contact = await _context.Contact.FindAsync(id);

            _context.Contact.Remove(contact);
            var dependent = await _context.Dependent.FindAsync(id);

            _context.Dependent.Remove(dependent);
            var deposit = await _context.Deposit.FindAsync(id);

            _context.Deposit.Remove(deposit);
            var appointment = await _context.Appointment.FindAsync(id);

            _context.Appointment.Remove(appointment);
            await _context.SaveChangesAsync();

            return(RedirectToAction("AdminList", "Customers"));
        }