示例#1
0
        public int AddStationLocation(StationLocationDto requestDto)
        {
            try
            {
                var code = LastCodeStationLocation();

                var decriptCode     = EncoderAgent.EncryptString((int.Parse(code)).ToString());
                var stationLocation = new StationLocation
                {
                    FkStationId  = requestDto.StationId,
                    FkLocationId = requestDto.LocationId,
                    Code         = decriptCode,
                    Sno          = requestDto.Sno
                };

                _context.StationLocation.Add(stationLocation);
                _context.SaveChanges();
                return(stationLocation.PkStationLocationId);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#2
0
        public async Task <ActivityPerformDto> GetStationActivityByCode(string code)
        {
            var encrptCode = EncoderAgent.EncryptString(code);
            var stationId  = _context.StationLocation
                             .AsNoTracking()
                             .Where(i => i.Code == code)
                             .Select(p => new { p.FkStationId, p.FkStation.Name, p.PkStationLocationId, p.Sno })
                             .SingleOrDefault();

            if (stationId != null && stationId.FkStationId != 0)
            {
                var activities = _context.StationActivity
                                 .AsNoTracking()
                                 .Where(i => i.FkStationId == stationId.FkStationId)
                                 .Select(p => new ActivityPerformDetailDto
                {
                    ActivityName      = p.FkActivity.Name,
                    ActivityId        = p.FkActivityId,
                    ActivityTypeId    = p.FkActivity.FkActivityTypeId,
                    StationActivityId = p.PkStationActivityId,
                    Type = p.FkActivity.FkActivityType.Type
                })
                                 .ToList();
                return(await Task.FromResult(new ActivityPerformDto
                {
                    Activities = activities,
                    StationLocationId = stationId.PkStationLocationId,
                    StationName = stationId.Name
                }));
            }
            return(await Task.FromResult(new ActivityPerformDto
            {
            }));
        }