示例#1
0
        public static void registeruser(SPRegisterClass NewSP)
        {
            var k = new ServicesContext();
            BankAccountDetails bank = new BankAccountDetails();

            bank.BankName      = NewSP.BankName;
            bank.AccountNumber = NewSP.BankAccNumber;

            k.BankAccounts.Add(bank);

            User UserObj = new User();

            UserObj.Username = NewSP.Username;
            UserObj.Password = NewSP.Password;
            UserObj.Type     = "SERVICE PROVIDER";
            k.Users.Add(UserObj);

            ServiceProviderDetails serviceProvider = new ServiceProviderDetails();

            serviceProvider.UserId  = UserObj.Id;
            serviceProvider.Contact = NewSP.Contact;
            serviceProvider.BankFK  = bank.Id;
            k.ServiceProviders.Add(serviceProvider);

            var ServiceId = k.Services.Where(g => g.Service == NewSP.Service).Select(g => g.Id).FirstOrDefault();

            ServicesAssigned service = new ServicesAssigned();

            service.ServiceProviderFK = serviceProvider.Id;
            service.ServicesFK        = ServiceId;
            service.Charge            = NewSP.Charge;
            k.ServicesAssigned.Add(service);

            k.SaveChanges();
        }
示例#2
0
        public static void AddUser(CustomerRegisterClass NewCustomer)
        {
            var s = new ServicesContext();

            BankAccountDetails bank = new BankAccountDetails();

            bank.BankName      = NewCustomer.BankName;
            bank.AccountNumber = NewCustomer.BankAccNumber;
            bank.Balance       = 1000.00m;
            s.BankAccounts.Add(bank);

            User UserObj = new User();

            UserObj.Username = NewCustomer.Username;
            UserObj.Password = NewCustomer.Password;
            UserObj.Type     = "CUSTOMER";
            s.Users.Add(UserObj);

            CustomerDetails customer = new CustomerDetails();

            customer.Contact  = NewCustomer.Contact;
            customer.UserId   = UserObj.Id;
            customer.Location = NewCustomer.Location;
            customer.BankFK   = bank.Id;
            s.Customers.Add(customer);

            s.SaveChanges();
        }