示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 public async Task CreateOrEdit(CreateOrEditLocationDto input)
 {
     if (input.Id == null)
     {
         await Create(input);
     }
     else
     {
         await Update(input);
     }
 }
示例#4
0
        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);
        }
示例#6
0
        private async Task Update(CreateOrEditLocationDto input)
        {
            var location = await _locationRepository.FirstOrDefaultAsync((int)input.Id);

            ObjectMapper.Map(input, location);
        }
示例#7
0
 public Task CreateOrEdit(CreateOrEditLocationDto input)
 {
     throw new System.NotImplementedException();
 }