Пример #1
0
        public async Task <ApiResponse> updatePort(TblPortMaster tblPortMaster)
        {
            _context.Entry(tblPortMaster).State = EntityState.Modified;
            _context.Entry(tblPortMaster).Property(i => i.RecordDate).IsModified = false;

            try
            {
                await _context.SaveChangesAsync();

                var listPortAgent = await _context.TblPortAgent.Where(i => i.PortId == tblPortMaster.Id).ToListAsync();

                _context.TblPortAgent.RemoveRange(listPortAgent);
                await _context.SaveChangesAsync();

                for (int i = 0; i < tblPortMaster.AgentArray.Length; i++)
                {
                    TblPortAgent obj = new TblPortAgent();
                    obj.AgentId = tblPortMaster.AgentArray[i];
                    obj.PortId  = tblPortMaster.Id;
                    _context.TblPortAgent.Add(obj);
                    await _context.SaveChangesAsync();
                }
                var ApiResponse = await response.ApiResult("OK", "", "Port Update");

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException)
            {
                var ApiResponseError = await response.ApiResult("OK", "", "Port Update");

                return(ApiResponseError);
            }
        }
Пример #2
0
        public async Task <IActionResult> PutTblStock(long id, TblStock tblStock)
        {
            if (id != tblStock.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tblStock).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblStockExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
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);
            }
        }
        public async Task <ApiResponse> updateCountry(TblCountryMaster tblCountryMaster)
        {
            if (tblCountryMaster.Id == 0)
            {
                var ApiResponse = await response.ApiResult("FAILED", "", "Error in Update");

                return(ApiResponse);
            }
            _context.Entry(tblCountryMaster).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", "", "update Record ");

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

                return(ApiResponse);
            }
        }
Пример #5
0
        public async Task <ApiResponse> UpdateCategory(TblCategoryMaster tblCategoryMaster)
        {
            _context.Entry(tblCategoryMaster).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", tblCategoryMaster.Id, " Update Record");

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException EX)
            {
                var ApiResponsError = await response.ApiResult("FAILED", EX, "Errro Updating");

                return(ApiResponsError);
            }
        }
Пример #6
0
        public async Task <ApiResponse> UpdateProduct(TblProduct tblProduct)
        {
            _context.Entry(tblProduct).State = EntityState.Modified;
            _context.Entry(tblProduct).Property(i => i.RecordDate).IsModified = false;
            try
            {
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", new { id = tblProduct.Id }, "Update Product Successfull");

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

                return(ApiResponse);
            }
        }
Пример #7
0
        public async Task <ApiResponse> UpdateAgent(TblAgentMaster tblAgentMaster)
        {
            _context.Entry(tblAgentMaster).State = EntityState.Modified;
            _context.Entry(tblAgentMaster).Property(x => x.RecordDate).IsModified = false;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                var ApiResponseError = await response.ApiResult("FAILED", "", "Agent Error Found");

                return(ApiResponseError);
            }

            var ApiResponse = await response.ApiResult("OK", tblAgentMaster.Id, "Update Agent");

            return(ApiResponse);
        }
Пример #8
0
        public async Task <ApiResponse> updateVesselMaster(TblVesselMaster tblVesselMaster)
        {
            _context.Entry(tblVesselMaster).State = EntityState.Modified;
            _context.Entry(tblVesselMaster).Property(i => i.RecordDate).IsModified = false;
            try
            {
                await _context.SaveChangesAsync();

                //remove vessel Route
                var listVesselRoute = await _context.TblVesselRoute.Where(i => i.VesselMasterId == tblVesselMaster.Id).ToListAsync();

                _context.TblVesselRoute.RemoveRange(listVesselRoute);
                await _context.SaveChangesAsync();

                List <TblVesselRoute> vesselRouteDetail = JsonConvert.DeserializeObject <List <TblVesselRoute> >(tblVesselMaster.VesselRouteDetail.ToString());
                for (int i = 0; i < vesselRouteDetail.Count; i++)
                {
                    TblVesselRoute objVesselRoute = new TblVesselRoute();
                    objVesselRoute.PortId          = vesselRouteDetail[i].PortId;
                    objVesselRoute.VesselMasterId  = tblVesselMaster.Id;
                    objVesselRoute.Type            = vesselRouteDetail[i].Type;
                    objVesselRoute.LastPuttingdate = vesselRouteDetail[i].LastPuttingdate;
                    _context.TblVesselRoute.Add(objVesselRoute);
                    await _context.SaveChangesAsync();
                }
                var ApiResponse = await response.ApiResult("OK", "", "Record Update");

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var ApiResponseEX = await response.ApiResult("OK", ex, "Record Found");

                return(ApiResponseEX);
            }
        }
Пример #9
0
        public async Task <ApiResponse> UpdateVesselName(long id, TblVesselName tblVesselName)
        {
            _context.Entry(tblVesselName).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", "", "Record Add");

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var ApiResponseError = await response.ApiResult("OK", ex, "Record Add");

                return(ApiResponseError);
            }
        }
Пример #10
0
        public async Task <ApiResponse> updateColor(TblColor tblColor)
        {
            _context.Entry(tblColor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", new { id = tblColor.Id }, "Update Record");

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

                return(ApiResponse);
            }
        }
Пример #11
0
        public async Task <ApiResponse> InstallmentPay(TblInstallmentDetail objInsDetail)
        {
            _context.Entry(objInsDetail).Property(x => x.InstallmentGivenDate).IsModified = true;
            _context.Entry(objInsDetail).Property(x => x.PaymentBy).IsModified            = true;
            _context.Entry(objInsDetail).Property(x => x.ReffNo).IsModified        = true;
            _context.Entry(objInsDetail).Property(x => x.PaidAmount).IsModified    = true;
            _context.Entry(objInsDetail).Property(x => x.PaymentStatus).IsModified = true;
            try
            {
                var response = await _context.SaveChangesAsync();

                var ApiResponse = await InstallmentDetailById(objInsDetail);

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var ApiResponseCatch = await response.ApiResult("FALIED", ex, "Erro In Update ");

                return(ApiResponseCatch);
            }
        }