Beispiel #1
0
 public Station(StationDto dto)
 {
     Id             = dto.Id;
     MapCoordinates = dto.MapCoordinates;
     Latitude       = dto.Latitude;
     Longitude      = dto.Longitude;
 }
Beispiel #2
0
        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();
                }
            }
        }
Beispiel #3
0
        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;
                }
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #8
0
        /// <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);
        }
Beispiel #9
0
        //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);
        }
Beispiel #10
0
        // 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);
        }
Beispiel #11
0
        //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);
        }
Beispiel #13
0
        // 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);
        }
Beispiel #14
0
        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);
        }
Beispiel #15
0
        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;
 }
Beispiel #17
0
        // 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));
        }
Beispiel #19
0
        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);
        }
Beispiel #20
0
        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);
        }
Beispiel #21
0
        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);
        }
Beispiel #22
0
        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();
        }
Beispiel #23
0
        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);
        }
Beispiel #24
0
        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> >()));
        }
Beispiel #25
0
        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));
        }
Beispiel #26
0
        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));
        }
Beispiel #29
0
        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));
        }
Beispiel #30
0
        //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 };
        }