Beispiel #1
0
 public IActionResult Create([FromBody] RegisterModel Users)
 {
     if (ModelState.IsValid)
     {
         var                 userId = Guid.NewGuid();
         UserModel           db     = new UserModel();
         BillingAddressModel db2    = new BillingAddressModel();
         ClientModel         db3    = new ClientModel();
         db.UserId                    = userId;
         db.RoleId                    = 1;
         db.Password                  = GeneratePassword();
         db.Salutation                = Users.Salutation;
         db.FirstName                 = Users.FirstName;
         db.LastName                  = Users.LastName;
         db.ContactNumber             = Users.ContactNumber;
         db.OfficeNumber              = Users.OfficeNumber;
         db.Email                     = Users.Email;
         db.IsActive                  = true;
         db.IsApproved                = false;
         db.IsFirstLogin              = true;
         db.CreatedBy                 = userId.ToString();
         db.CreatedDate               = DateTime.Now;
         db2.BillingId                = db.UserId;
         db2.BillingFName             = Users.FirstName;
         db2.BillingLName             = Users.LastName;
         db2.BillingCompanyName       = Users.CompanyName;
         db2.BillingNickname          = Users.Address;
         db2.BillingAddressStreet     = Users.Street;
         db2.BillingAddressApartment  = Users.Apartment;
         db2.BillingAddressTown       = Users.Town;
         db2.BillingCountry           = Users.Country;
         db2.BillingAddressPostalcode = Users.PostalCode;
         db2.BillingAddressPhone      = Int32.Parse(Users.ContactNumber);
         db2.BillingAddressEmail      = Users.Email;
         db2.CreatedDate              = DateTime.Now;
         db2.CreatedBy                = userId.ToString();
         db2.IsActive                 = true;
         db3.ClientId                 = db.UserId;
         db3.CompanyName              = Users.CompanyName;
         db3.CompanyAddress           = Users.Address;
         db3.IsActive                 = true;
         db3.CreatedDate              = DateTime.Now;
         db3.CreatedBy                = userId.ToString();
         _dataAccessProvider.AddRecord(db);
         _dataAccessProvider.AddBillingRecord(db2);
         _dataAccessProvider.AddClientRecord(db3);
         return(Ok(new { proceed = true }));
     }
     return(BadRequest(ModelState.IsValid));
 }