コード例 #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 <int> UpdateStationLocation(StationLocationDto requestDto)
        {
            try
            {
                var stationLocation = _context.StationLocation.Find(requestDto.StationLocationId);
                stationLocation.FkStationId  = requestDto.StationId;
                stationLocation.FkLocationId = requestDto.LocationId;
                stationLocation.Sno          = requestDto.Sno;
                //var stationlocation = new StationLocation
                //{
                //    PkStationLocationId = requestDto.StationLocationId,
                //    FkStationId = requestDto.StationId,
                //    FkLocationId = requestDto.LocationId
                //};

                _context.StationLocation.Update(stationLocation);
                _context.SaveChanges();

                return(await Task.FromResult(stationLocation.PkStationLocationId));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                throw;
            }
        }