protected virtual async Task Create(CreateOrEditLocationDto input) { var location = ObjectMapper.Map <Location>(input); location.Machines = new List <LocationMachine>(); //location.LocationCredentials = new List<LocationCredential>(); //if (input.LocationCredentials.Count > 0) //{ // foreach (var item in input.LocationCredentials) // { // location.LocationCredentials.Add(ObjectMapper.Map<LocationCredential>(item)); // } //} if (input.Machines.Count > 0) { foreach (var item in input.Machines) { location.Machines.Add(ObjectMapper.Map <LocationMachine>(item)); } } await _locationRepository.InsertAsync(location); }
protected virtual async Task Update(CreateOrEditLocationDto input) { var location = await _locationRepository.GetAllIncluding(m => m.LocationCredentials).FirstOrDefaultAsync(x => x.Id == (int)input.Id); var oldLocationCredentials = new HashSet <LocationCredential>(location.LocationCredentials.ToList()); var newLocationCredentials = new HashSet <LocationCredentialDto>(input.LocationCredentials.ToList()); foreach (var detail in oldLocationCredentials) { if (!newLocationCredentials.Any(x => x.Id == detail.Id)) { location.LocationCredentials.Remove(detail); } else { var inputDetail = newLocationCredentials.Where(x => x.Id == detail.Id).FirstOrDefault(); detail.Longitude = inputDetail.Longitude; detail.Latitude = inputDetail.Latitude; } } foreach (var item in newLocationCredentials) { if (item.Id == 0) { location.LocationCredentials.Add(ObjectMapper.Map <LocationCredential>(item)); } } location.TitleAr = input.TitleAr; location.TitleEn = input.TitleEn; await _locationRepository.UpdateAsync(location); }
public async Task CreateOrEdit(CreateOrEditLocationDto input) { if (input.Id == null) { await Create(input); } else { await Update(input); } }
private async Task Create(CreateOrEditLocationDto input) { var location = ObjectMapper.Map <Location>(input); if (AbpSession.TenantId != null) { location.TenantId = AbpSession.TenantId.GetValueOrDefault(-1); } await _locationRepository.InsertAsync(location); }
protected virtual async Task Create(CreateOrEditLocationDto input) { var location = ObjectMapper.Map <Location>(input); if (AbpSession.TenantId != null) { location.TenantId = (int?)AbpSession.TenantId; } await _locationRepository.InsertAsync(location); }
private async Task Update(CreateOrEditLocationDto input) { var location = await _locationRepository.FirstOrDefaultAsync((int)input.Id); ObjectMapper.Map(input, location); }
public Task CreateOrEdit(CreateOrEditLocationDto input) { throw new System.NotImplementedException(); }