public async Task <int> UpdateAsync(Address address) { var rowsChanged = 0; if (address?.City?.Country != null) { address.City.Country.LastUpdated = DateTime.UtcNow; await _sqlOrm.ExecuteAsync(UpdateSql.Country, address.City.Country); rowsChanged++; } if (address?.City != null) { address.City.CountryId = address.City.Country.Id; address.City.LastUpdated = DateTime.UtcNow; await _sqlOrm.ExecuteAsync(UpdateSql.City, address.City); rowsChanged++; } if (address != null) { address.CityId = address.City.Id; address.LastUpdated = DateTime.UtcNow; await _sqlOrm.ExecuteAsync(UpdateSql.Address, address); rowsChanged++; } return(rowsChanged); }
public async Task <int> UpdateAsync(Appointment appointment) { 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); await _sqlOrm.ExecuteAsync(UpdateSql.Appointment, appointment); return(1); }
public async Task <int> UpdateAsync(Customer customer) { if (customer == null) { throw new ArgumentNullException(nameof(customer)); } ValidateCustomerInputs(customer); var rowsChanged = await _addressRepository.UpdateAsync(new Address { Id = customer.AddressId, Address1 = customer.Address1, Address2 = customer.Address2, Phone = customer.Phone, PostalCode = customer.PostalCode, LastUpdatedBy = customer.LastUpdatedBy, LastUpdated = DateTime.UtcNow, City = new City { Id = customer.CityId, Name = customer.City, LastUpdatedBy = customer.LastUpdatedBy, LastUpdated = DateTime.UtcNow, Country = new Country { Id = customer.CountryId, Name = customer.Country, LastUpdatedBy = customer.LastUpdatedBy, LastUpdated = DateTime.UtcNow, } } }); customer.LastUpdated = DateTime.UtcNow; await _sqlOrm.ExecuteAsync(UpdateSql.Customer, customer); return(rowsChanged += 1); }
public async Task <bool> CheckUsernameExists(string username) { var result = await _sqlOrm.ExecuteAsync(SelectSql.UsernameCount, new { username }); return(result > 0); }