Esempio n. 1
0
        public async Task <int> CreateAsync(Address newAddress)
        {
            newAddress.City.Country.CreatedDate = DateTime.UtcNow;
            newAddress.City.Country.LastUpdated = DateTime.UtcNow;
            var countryId = await _sqlOrm.CreateEntityAsync(CreateSql.Country, newAddress.City.Country);

            newAddress.City.CountryId   = countryId;
            newAddress.City.CreatedDate = DateTime.UtcNow;
            newAddress.City.LastUpdated = DateTime.UtcNow;
            var cityId = await _sqlOrm.CreateEntityAsync(CreateSql.City, newAddress.City);

            newAddress.CityId      = cityId;
            newAddress.CreatedDate = DateTime.UtcNow;
            newAddress.LastUpdated = DateTime.UtcNow;
            return(await _sqlOrm.CreateEntityAsync(CreateSql.Address, newAddress));
        }
Esempio n. 2
0
        public async Task <int> CreateAsync(Appointment appointment)
        {
            appointment.CreatedDate = DateTime.UtcNow;
            appointment.LastUpdated = DateTime.UtcNow;

            // Remove Seconds from schedule
            appointment.Start = new DateTime(appointment.Start.Year, appointment.Start.Month, appointment.Start.Day, appointment.Start.Hour, appointment.Start.Minute, 0);
            appointment.End   = new DateTime(appointment.End.Year, appointment.End.Month, appointment.End.Day, appointment.End.Hour, appointment.End.Minute, 0);
            await AppointmentValidation(appointment);

            return(await _sqlOrm.CreateEntityAsync(CreateSql.Appointment, appointment));
        }
Esempio n. 3
0
        public async Task <User> CreateAsync(User user)
        {
            user.Password    = HashPassword(user.Password);
            user.CreatedDate = DateTime.UtcNow;
            user.LastUpdated = DateTime.UtcNow;

            _ = await _sqlOrm.CreateEntityAsync(CreateSql.User, user);

            var result = await _sqlOrm.QueryAsync <User>(SelectSql.User, user);

            result.Password = null;
            return(result);
        }
Esempio n. 4
0
        public async Task <int> CreateAsync(Customer customer)
        {
            ValidateCustomerInputs(customer);
            var addressId = await _addressRepository.CreateAsync(new Address
            {
                Address1      = customer.Address1,
                Address2      = customer.Address2,
                Phone         = customer.Phone,
                PostalCode    = customer.PostalCode,
                CreatedBy     = customer.CreatedBy,
                LastUpdatedBy = customer.LastUpdatedBy,
                CreatedDate   = DateTime.UtcNow,
                LastUpdated   = DateTime.UtcNow,
                City          = new City
                {
                    Name          = customer.City,
                    CreatedBy     = customer.CreatedBy,
                    LastUpdatedBy = customer.LastUpdatedBy,
                    CreatedDate   = DateTime.UtcNow,
                    LastUpdated   = DateTime.UtcNow,
                    Country       = new Country
                    {
                        Name          = customer.Country,
                        CreatedBy     = customer.CreatedBy,
                        LastUpdatedBy = customer.LastUpdatedBy,
                        CreatedDate   = DateTime.UtcNow,
                        LastUpdated   = DateTime.UtcNow,
                    }
                }
            });

            customer.AddressId   = addressId;
            customer.CreatedDate = DateTime.UtcNow;
            customer.LastUpdated = DateTime.UtcNow;
            var customerId = await _sqlOrm.CreateEntityAsync(CreateSql.Customer, customer);

            return(customerId);
        }