public Station(StationDto dto) { Id = dto.Id; MapCoordinates = dto.MapCoordinates; Latitude = dto.Latitude; Longitude = dto.Longitude; }
public async Task AddNewStation(StationDto stationDto, string nameRailwayStation) { using (var uow = new UnitOfWork(new CisDbContext(_optionsBuilder.Options))) { if (string.IsNullOrEmpty(nameRailwayStation)) { return; } if (stationDto == null) { return; } var railwayStation = await uow.RailwayStationRepository.Get().Include(rs => rs.Stations).FirstOrDefaultAsync(n => n.Name.Equals("Ленинградский")); if (railwayStation != null) { railwayStation.Stations.Add(new RailwayStStationStations { RailStId = railwayStation.Id, StationDto = stationDto }); await uow.SaveAsync(); } } }
public async Task <bool> RemoveStation(StationDto stationDto) { using (var uow = new UnitOfWork(new CisDbContext(_optionsBuilder.Options))) { try { if (stationDto != null && await uow.StationRepository.Exists(stationDto)) { uow.StationRepository.Remove(stationDto); await uow.SaveAsync(); return(true); } return(false); } catch (DbUpdateConcurrencyException) { var findStation = uow.StationRepository.GetById(stationDto.Id); if (findStation != null) //уже удалили из паралельного потока { return(false); } throw; } } }
public async Task <bool> UpdateAsync(StationDto dto) { var entity = _context.Stations.FirstOrDefault(u => u.Id == dto.Id); _mapper.Map(dto, entity); return(await _context.SaveChangesAsync() > 0); }
public async Task AddStationAsync(StationDto station) { context.Stations.Add(new Station { Name = station.Name, DistrictId = station.DistrictId, TalukaId = station.TalukaId, VillageId = station.VillageId }); await context.SaveChangesAsync(); }
public IActionResult Edit(int id, StationDto stationDto) { log.Info(nameof(StationController.Edit) + " POST"); if (id != stationDto.Id) { log.Warn(nameof(StationController.Edit) + " id is not equal to stationDto.Id"); return(NotFound()); } try { if (ModelState.IsValid) { stationService.Update(stationDto); return(RedirectToAction(nameof(Index))); } ViewData["AreaId"] = new SelectList(areaService.GetAreas(), "Id", "Name", stationDto.AreaId); return(View(stationDto)); } catch (Exception e) { log.Error(e); return(BadRequest()); } }
public async Task <PageDto <StationDto> > GetPageAsync(int pageSize, int pageNumber) { var page = new PageDto <StationDto>(pageSize, pageNumber); var items = await _unitOfWork.Stations.GetPageAsync(pageSize, pageNumber); page.SetData(items.Item2, items.Item1.Select(i => StationDto.FromDomain(i)).ToList()); return(page); }
/// <summary> /// 增 /// </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <string> AddAsync(StationDto dto) { var entity = _mapper.Map <StationDto, StationEntity>(dto); entity.Init(); _context.Stations.Add(entity); return(await _context.SaveChangesAsync() > 0 ? entity.Id : string.Empty); }
//get applied volume per station public double GetTotalAppliedVolumeByStation(StationDto Station, FinancialYearDto FinancialYear) { var Volume = _candidateRepository.GetAll() .Where(x => x.StationId == Station.Id) .Where(x => x.FinancialYearId == FinancialYear.Id) .Sum(x => (double?)x.AllocatedCubicMetres) ?? 0.00; return(Volume); }
// Sum of Bills in a Financial Year by station public int GetTotalBillsByStation(StationDto Station, FinancialYearDto FinancialYear) { var bills = _billRepository.GetAll() .Where(x => x.StationId == Station.Id) .Where(x => x.FinancialYearId == FinancialYear.Id) .Count(); return(bills); }
//tottal selected candidates public int GetTotalCandidatesByStationId(StationDto Station, FinancialYearDto FinancialYear) { var candidates = _candidateRepository.GetAll() .Where(x => x.StationId == Station.Id) .Where(x => x.FinancialYearId == FinancialYear.Id) .Count(); return(candidates); }
public async Task <StationDto> GetAsync(int id) { var dto = await _cacheStore.StoreAndGetAsync(GetCacheKey(id), async() => { var item = await Get(id); return(StationDto.FromDomain(item)); }); return(dto); }
// Sum of Registered Dealers in a Financial Year public int GetTotalPendingDealerByStationId(StationDto Station, FinancialYearDto FinancialYear) { var dealers = _dealerRepository.GetAll() .Where(x => x.StationId == Station.Id) .Where(x => x.FinancialYearId == FinancialYear.Id) .Where(x => x.BillControlNumber == null) .Count(); return(dealers); }
public async Task DeleteStationAsync(StationDto input) { var station = _stationRepository.FirstOrDefault(input.Id); if (station == null) { throw new UserFriendlyException("Station Year not Found!"); } await _stationRepository.DeleteAsync(station); }
public int GetTotalPendingBillsByStation(StationDto Station, FinancialYearDto FinancialYear) { var bills = _billRepository.GetAll() .Where(p => p.PaidAmount == 0) .Where(p => p.FinancialYearId == FinancialYear.Id) .Where(p => p.StationId == Station.Id) .Count(); return(bills); }
public StationModel(StationDto dto, string playlistFormat) { BitRate = dto.BitRate; CurrentTrack = dto.CurrentTrack; Genre = dto.Genre; StationId = dto.Id; MediaType = dto.MediaType; Name = dto.Name; M3Url = $"http://yp.shoutcast.com/{playlistFormat}?id={StationId}"; LogoUrl = dto.LogoUrl; }
// Sum of Registered Dealers in a Month in Financial Year public int GetTotalMonthPendingDealerByStationId(StationDto Station, FinancialYearDto FinancialYear) { var dealers = _dealerRepository.GetAll() .Where(x => x.StationId == Station.Id) .Where(x => x.FinancialYearId == FinancialYear.Id) .Where(x => x.BillControlNumber == null) .Where(x => x.CreationTime.Month == DateTime.Today.Month && x.CreationTime.Year == DateTime.Today.Year) .Count(); return(dealers); }
public async Task <IActionResult> Post([FromBody] StationDto station) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await stationRepository.AddStationAsync(station); return(Created("contextapi/station", station)); }
public List <double> GetTotalPaymentsAmountByStation(StationDto Station, FinancialYearDto FinancialYear) { var bills = _billRepository.GetAll() .Where(p => p.PaidAmount > 0) .Where(p => p.FinancialYearId == FinancialYear.Id) .Where(p => p.StationId == Station.Id) .Select(p => p.PaidAmount) .ToList(); return(bills); }
public async Task UpdateStation(StationDto input) { var station = _stationRepository.FirstOrDefault(input.Id); station.Name = input.Name; station.Address = input.Address; station.ZoneId = input.ZoneId; station.RegionId = input.RegionId; await _stationRepository.UpdateAsync(station); }
public int GetTotalMonthPendingBillsByStation(StationDto Station, FinancialYearDto FinancialYear) { var bills = _billRepository.GetAll() .Where(x => x.StationId == Station.Id) .Where(x => x.FinancialYearId == FinancialYear.Id) .Where(p => p.PaidAmount == 0) .Where(x => x.IssuedDate.Month == DateTime.Today.Month && x.IssuedDate.Year == DateTime.Today.Year) .Count(); return(bills); }
public void Update(StationDto stationDto) { if (!stationValidator.Validate(stationDto).IsValid) { throw new ArgumentException(stationValidator.Validate(stationDto).Errors.First().ErrorMessage); } var station = mapper.Map <StationDto, Station>(stationDto); uow.Stations.Update(station); uow.Save(); }
public List <double> GetTotalMonthPaymentsAmountByStation(StationDto Station, FinancialYearDto FinancialYear) { var bills = _billRepository.GetAll() .Where(p => p.PaidAmount > 0) .Where(p => p.FinancialYearId == FinancialYear.Id) .Where(p => p.StationId == Station.Id) .Where(x => x.IssuedDate.Month == DateTime.Today.Month && x.IssuedDate.Year == DateTime.Today.Year) .Select(p => p.PaidAmount) .ToList(); return(bills); }
public List <CandidateDto> GetCandidates(FinancialYearDto FinancialYear, StationDto Station) { var candidates = _candidateRepository .GetAll() .OrderBy(p => p.Name) .Where(p => p.FinancialYearId == FinancialYear.Id) .Where(p => p.StationId == Station.Id) .Where(p => p.IsRegistered == false) .ToList(); return(new List <CandidateDto>(candidates.MapTo <List <CandidateDto> >())); }
public async Task <IActionResult> Add(StationDto dto) { if (ModelState.IsValid) { var result = await _stationservice.AddAsync(dto); if (result.IsNotBlank()) { return(RedirectToAction("Index")); } } return(View(dto)); }
public AjaxResult Station([FromBody] dynamic Json) { #region //数据操作 AjaxResult result = new AjaxResult(); result.Code = DoResult.Success; StationDto dto = new StationDto(); dto.StationList = tmb_area.DataTableToList(tmb_area.GetStation().Tables[0]); result.Result = SerializationHelper.JsonSerialize(dto); #endregion return(result); }
public async Task <StationDto> CreateAsync(StationDto dto) { await _unitOfWork.Stations.GuardForDuplicateDepoName(dto.Name); var station = new Station(dto.Name, dto.OrganizationId, dto.PreStationId, dto.PostStationId); station.SetPosition(dto.Latitude, dto.Longitude, dto.Altitude); await _unitOfWork.CompleteAsync(ctx => ctx.Stations.AddAsync(station)); dto.Id = station.Id; return(dto); }
public async Task <IEnumerable <StationDto> > GetByOrganizationAsync(int id) { var items = await _unitOfWork.Stations.GetAsync(s => s.OrganizationId == id); IEnumerable <StationDto> ConvertToDtoList(IEnumerable <Station> list) { foreach (var item in list) { yield return(StationDto.FromDomain(item)); } } return(ConvertToDtoList(items)); }
public async Task <IActionResult> Edit(StationDto dto) { if (!ModelState.IsValid) { return(View(dto)); } var result = await _stationservice.UpdateAsync(dto); if (result) { return(RedirectToAction("Index")); } return(View(dto)); }
//get total fees from dealer registration in a financial year in a current month per station public List <double> GetTotalMonthDealerFeesByStation(StationDto Station, FinancialYearDto FinancialYear) { var fees = from l in _dealerRepository.GetAll() join a in _dealerActivityRepository.GetAll() on l.Id equals a.DealerId join i in _activityRepository.GetAll() on a.ActivityId equals i.Id where l.FinancialYearId == FinancialYear.Id where l.StationId == Station.Id //where l.ReceiptNumber != null where (l.CreationTime.Month == DateTime.Today.Month && l.CreationTime.Year == DateTime.Today.Year) group i by l.StationId into g select g.Sum(x => x.Fee); return(fees.ToList()); }
public static StationDto Create(Station s, ProductionOrder order = null, DvseMeter meter = null) { var dto = new StationDto() { ComPort = s.ComPort, ComParamStatus = s.ComParamStatus, ScanMatrixStatus = s.ScanMatrixStatus, ScanPcbStatus = s.ScanPcbStatus, OrderUniqueId = s.OrderUniqueId, Order = order, ConfigurationOptions = s.ConfigurationOptions, MeterNo = s.MeterNo, Meter = meter, Number = s.Number, ParameterInfoSetName = order != null ? order.ParameterInfoSetName : string.Empty }; return dto; }
private IEnumerable<StationDto> MoqStations() { StationDto one = new StationDto(); one.Name = "Heuston"; one.Number = 1; one.Address = "Heuston"; one.Banking = true; one.Status = "Open"; one.Bike_Stands = "20"; one.Available_Bike_Stands = "10"; one.Available_Bikes = "10"; StationDto two = new StationDto(); two.Name = "Smithfield"; two.Number = 2; two.Address = "Smithfield"; two.Banking = true; two.Status = "Open"; two.Bike_Stands = "30"; two.Available_Bike_Stands = "20"; two.Available_Bikes = "10"; return new List<StationDto> { one, two }; }