示例#1
0
        public async Task <ApiResponse> GetYardById(TblYard objyard)
        {
            var listYard = await _context.TblYard.Where(i => i.Id == objyard.Id).ToListAsync();

            var listYardlocation = await _context.TblYardLocation.Where(i => i.YardId == objyard.Id).ToListAsync();

            var items = (from ly in listYard
                         join lyl in listYardlocation on ly.Id equals lyl.YardId
                         select new
            {
                id = ly.Id,
                name = ly.Name,
                numberOfFreeDay = ly.NumberOfFreeDay,
                agentId = ly.AgentId,
                portId = ly.PortId,
                handlingChages = ly.HandlingChages,
                radiationCharges = ly.RadiationCharges,
                godownCharges = ly.GodownCharges,
                otherCharges = ly.OtherCharges,
                countryId = lyl.CountryId
            }).ToList();


            var ApiResponse = await response.ApiResult("OK", items, "Data Found");

            return(ApiResponse);
        }
示例#2
0
        public async Task <ApiResponse> UpdateYard(TblYard tblYard)
        {
            _context.Entry(tblYard).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                var tblYardlocation = await _context.TblYardLocation.Where(i => i.YardId == tblYard.Id).ToListAsync();

                _context.TblYardLocation.RemoveRange(tblYardlocation);
                await _context.SaveChangesAsync();

                TblYardLocation objYardLocation = new TblYardLocation();
                objYardLocation.YardId              = tblYard.Id;
                objYardLocation.CountryId           = tblYard.CountryId;
                objYardLocation.LocationDiscription = tblYard.LocationDescription;
                _context.TblYardLocation.Add(objYardLocation);
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", tblYard, "Data Found");

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var ApiResponse = await response.ApiResult("FAILED", ex, "Error in update");

                return(ApiResponse);
            }
        }
示例#3
0
        public async Task <ApiResponse> AddYard(TblYard tblYard)
        {
            _context.TblYard.Add(tblYard);
            await _context.SaveChangesAsync();

            TblYardLocation objYardLocation = new TblYardLocation();

            objYardLocation.YardId              = tblYard.Id;
            objYardLocation.CountryId           = tblYard.CountryId;
            objYardLocation.LocationDiscription = tblYard.LocationDescription;
            _context.TblYardLocation.Add(objYardLocation);
            await _context.SaveChangesAsync();

            var ApiResponse = await response.ApiResult("OK", new { id = tblYard.Id }, "Add Yard");

            return(ApiResponse);
        }