예제 #1
0
        public void Test_RawCust_Theory(string expected)
        {
            var sut = new RawCust()
            {
                Fname    = "Tris",
                Lname    = "Linde",
                Username = "******",
                Password = "******"
            };

            var actual = sut.Fname + sut.Lname + sut.Username + sut.Password;

            Assert.Equal(expected, actual);
        }
예제 #2
0
        public Customer Register(RawCust rawCust)
        {
            if (_repolayer.UserExists(rawCust.Username) == true)
            {
                return null;
            }
            else
            {
                //convert this rawperson to a Person
                // send in the submitted password and get back a Person obj with the hashed password and key for it.
                Customer newCustomer = mapper.GetANewCustomerWithHashedPassword(rawCust.Password);

                //transfer in the supplied data
                newCustomer.Fname = rawCust.Fname;
                newCustomer.Lname = rawCust.Lname;
                newCustomer.UserName = rawCust.Username;
                Customer registeredCustomer = _repolayer.Register(newCustomer);//call a method on the repo layer to save the new person to the DB.
                return registeredCustomer;
            }
        }
예제 #3
0
        public ActionResult <Customer> Register(RawCust rawCust)
        {
            System.Console.WriteLine(rawCust.Fname);
            Customer customer = new Customer();

            if (!ModelState.IsValid)// did the conversion from JS to C# work?
            {
                // return StatusCode(409, $"User '{rawPerson.UserName}' already exists.");
                return(StatusCode(400, "That was a failue of modelbinding"));
            }
            else
            {
                // here you will use the bussiness logic layer instance to pass the data to that layer and eventually save it to the Db.
                //Console.WriteLine($"{rawperson.Fname}, {rawperson.Lname}");
                customer = _business.Register(rawCust);
            }

            //check if person is null!!!
            if (customer == null)
            {
                return(StatusCode(409, "We're sorry, your new user was not successfully saved or a user of that username already exists."));
            }
            return(customer);
        }