public async Task <GetHerdGeoLogForEditOutput> GetHerdGeoLogForEdit(NullableIdDto <int> input) { HerdGeoLog herdGeoLog = null; if (input.Id.HasValue) { herdGeoLog = await _herdGeoLogRepository.GetAll() .FirstOrDefaultAsync(x => x.Id == input.Id.Value); } var output = new GetHerdGeoLogForEditOutput(); //herdGeoLog output.HerdGeoLog = herdGeoLog != null ? ObjectMapper.Map <HerdGeoLogCreateOrUpdateInput>(herdGeoLog) : new HerdGeoLogCreateOrUpdateInput(); //StateInfos output.Herds = _herdRepository .GetAllList() .Select(c => new ComboboxItemDto(c.Id.ToString(), c.Code + " - " + c.HerdName + "(" + c.Name + "," + c.Family + ")")) .ToList(); return(output); }
private async Task CreateHerdAsync(HerdCreateOrUpdateInput input) { var herd = ObjectMapper.Map <Herd>(input); await _herdRepository.InsertAsync(herd); await CurrentUnitOfWork.SaveChangesAsync(); var herdGeoLog = new HerdGeoLog { HerdId = herd.Id, Latitude = herd.Latitude, Longitude = herd.Longitude, CreationTime = herd.CreationTime }; await _herdGeoLogInfoRepository.InsertAsync(herdGeoLog); if (herd.Id > 0) { var officer = _officerRepository.FirstOrDefault(x => x.UserId == AbpSession.UserId); var message = "گله شما با کد " + herd.Code + " در سامانه دامیار توسط " + officer?.Name + " " + officer?.Family + " ثبت شد."; await _sms98Sender.SendAsync(herd.Mobile.Replace("-", ""), message); } }