Exemplo n.º 1
0
        public static bool RegisterUser(ModelLibrary.Customer mCus, string passwordHashed)
        {
            var customer = ConvertCustomerToDatabase(mCus);

            if (customer == null)
            {
                return(false);
            }

            var db = new JustFeastDbDataContext();

            if (db.Customers.Any(x => x.email.Equals(customer.email)))
            {
                return(false);
            }

            db.Customers.InsertOnSubmit(customer);
            db.SubmitChanges();

            db.Users.InsertOnSubmit(new DatabaseAccessLibrary.User
            {
                customerId = db.Customers.FirstOrDefault(x => x.email == customer.email).id,
                password   = passwordHashed
            });
            db.SubmitChanges();
            return(true);
        }
Exemplo n.º 2
0
        public static ModelLibrary.Customer ConvertCustomerToModel(DatabaseAccessLibrary.Customer customer)
        {
            if (customer == null)
            {
                return(null);
            }

            var mCus = new ModelLibrary.Customer
            {
                Address = customer.address,
                Email   = customer.email,
                Id      = customer.id,
                Name    = customer.name,
                RoleId  = customer.roleId,
                PhoneNo = customer.phoneNo.ToString()
            };

            return(mCus);
        }
Exemplo n.º 3
0
        public static DatabaseAccessLibrary.Customer ConvertCustomerToDatabase(ModelLibrary.Customer mCus)
        {
            if (mCus == null)
            {
                return(null);
            }

            var customer = new DatabaseAccessLibrary.Customer
            {
                address = mCus.Address,
                email   = mCus.Email,
                id      = mCus.Id,
                name    = mCus.Name,
                roleId  = mCus.RoleId,
            };

            Int32.TryParse(mCus.PhoneNo, out int no);
            customer.phoneNo = no;

            return(customer);
        }
Exemplo n.º 4
0
 public bool RegisterUser(ModelLibrary.Customer customer, string passwordHashed)
 {
     return(CustomerCtrl.RegisterUser(customer, passwordHashed));
 }