コード例 #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));
 }
コード例 #2
0
        public void Register(RegisterModel data)
        {
            UserModel           user    = new UserModel();
            BillingAddressModel billing = new BillingAddressModel();
            ClientModel         client  = new ClientModel();

            user.UserId                      = Guid.NewGuid();
            user.RoleId                      = 1;
            user.Password                    = "******";
            user.Salutation                  = data.Salutation;
            user.FirstName                   = data.FirstName;
            user.LastName                    = data.LastName;
            user.ContactNumber               = data.ContactNumber;
            user.OfficeNumber                = data.OfficeNumber;
            user.Email                       = data.Email;
            user.IsActive                    = true;
            user.IsApproved                  = false;
            user.IsFirstLogin                = true;
            user.CreatedBy                   = "qwerty";
            user.CreatedDate                 = DateTime.Now;
            billing.BillingId                = user.UserId;
            billing.BillingFName             = data.FirstName;
            billing.BillingLName             = data.LastName;
            billing.BillingCompanyName       = data.CompanyName;
            billing.BillingNickname          = data.Address;
            billing.BillingAddressStreet     = data.Street;
            billing.BillingAddressApartment  = data.Apartment;
            billing.BillingAddressTown       = data.Town;
            billing.BillingCountry           = data.Country;
            billing.BillingAddressPostalcode = data.PostalCode;
            billing.BillingAddressPhone      = Int16.Parse(data.ContactNumber);
            billing.BillingAddressEmail      = data.Email;
            billing.CreatedDate              = DateTime.Now;
            billing.CreatedBy                = "john";
            billing.IsActive                 = true;
            client.ClientId                  = user.UserId;
            client.CompanyName               = data.CompanyName;
            client.CompanyAddress            = data.Address;
            client.IsActive                  = true;
            client.CreatedDate               = DateTime.Now;
            client.CreatedBy                 = "john";
            _context.Users.Add(user);
            _context.SaveChanges();
            _context.BillingAddresses.Add(billing);
            _context.Clients.Add(client);
            _context.SaveChanges();
        }
コード例 #3
0
        public IActionResult GetCompanyProfileById(string id)
        {
            BillingAddressModel company = new BillingAddressModel();

            company.BillingId = Guid.Parse(id);
            company           = _dataAccessProvider.GetCompanyDetailByGUID(company);
            return(Ok(new
            {
                CompanyName = company.BillingCompanyName,
                AddressNickName = company.BillingNickname,
                Street = company.BillingAddressStreet,
                Apartment = company.BillingAddressApartment,
                Town = company.BillingAddressTown,
                Country = company.BillingCountry,
                PostalCode = company.BillingAddressPostalcode
            }));
        }
コード例 #4
0
        public async Task <IActionResult> EditBillingAddress(BillingAddressModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await GetCurrentUserAsync();

                Guid billingAddressId = Guid.NewGuid();

                // check if there are already billing address
                var billingAddressEntity = _billingAddressService.GetBillingAddressById(user.BillingAddressId);
                if (billingAddressEntity == null)
                {
                    billingAddressEntity    = _mapper.Map <BillingAddressModel, BillingAddress>(model);
                    billingAddressEntity.Id = billingAddressId;

                    // save billing address in database
                    _billingAddressService.InsertBillingAddress(billingAddressEntity);
                }
                else
                {
                    billingAddressId        = billingAddressEntity.Id;
                    billingAddressEntity    = _mapper.Map <BillingAddressModel, BillingAddress>(model);
                    billingAddressEntity.Id = billingAddressId;

                    // update billing address in database
                    _billingAddressService.UpdateBillingAddress(billingAddressEntity);
                }


                // update user billing address
                user.BillingAddressId = billingAddressEntity.Id;
                await _userManager.UpdateAsync(user);
            }

            return(View(model));
        }
コード例 #5
0
 public void AddBillingRecord(BillingAddressModel data)
 {
     _context.BillingAddresses.Add(data);
     _context.SaveChanges();
 }
コード例 #6
0
 //Retrieve Company Data based on UserId
 public BillingAddressModel GetCompanyDetailByGUID(BillingAddressModel companyData)
 {
     return(_context.BillingAddresses.FirstOrDefault(x => x.BillingId == companyData.BillingId));
 }