Exemplo n.º 1
0
        public List <LocationsDTO> MappingFromLocationToLOcationsDTO(IEnumerable <Location> LocationList)
        {
            List <LocationsDTO> locationDTOList = new List <LocationsDTO>();

            foreach (var Location in LocationList)
            {
                LocationsDTO locationDto = new LocationsDTO();
                locationDto.ID         = Location.ID;
                locationDto.Name       = Location.Name;
                locationDto.Identifier = Location.Identifier;
                locationDto.PropCode   = Location.PropCode;
                locationDto.RDUsageID  = Location.RDUsageID;
                if (locationDto.RDUsageID == 1)
                {
                    locationDto.RDB = "R";
                }
                else if (locationDto.RDUsageID == 2)
                {
                    locationDto.RDB = "D";
                }
                else
                {
                    locationDto.RDB = "B";
                }
                locationDto.IsActive     = Location.IsActive;
                locationDto.CreatedBy    = Location.CreatedBy;
                locationDto.CreatedDate  = Location.CreatedDate;
                locationDto.ModifiedBy   = Location.ModifiedBy;
                locationDto.ModifiedDate = Location.ModifiedDate;
                locationDTOList.Add(locationDto);
            }
            return(locationDTOList);
        }
Exemplo n.º 2
0
        public LocationsDTO GetLocationById(int id)
        {
            LocationsDTO result = new LocationsDTO();

            if (id != 0)
            {
                result = modalFactory.Parse(_ILocationRepository.GetLocationById(id));
            }
            else
            {
                result = new LocationsDTO();
            }
            if (result.RDUsageID == 1)
            {
                result.RDB = "R";
            }
            else if (result.RDUsageID == 2)
            {
                result.RDB = "D";
            }
            else
            {
                result.RDB = "B";
            }
            return(result);
        }
Exemplo n.º 3
0
        public ActionResult AddOrEdit(int id = 0)
        {
            LocationsDTO lstLocationsDTO = new LocationsDTO();

            if (id == 0)
            {
                return(View(new LocationsDTO()));
            }
            else
            {
                var request = new RestRequest(string.Format("EditLocation"), Method.POST)
                {
                    RequestFormat = DataFormat.Json
                };
                request.JsonSerializer = NewtonsoftJsonSerializer.Default;
                request.AddJsonBody(id);
                var response = clientLocation.Execute <LocationsDTO>(request);

                int totalRecords = 0;
                if (response.Data != null)
                {
                    lstLocationsDTO = response.Data;
                }
                else
                {
                    lstLocationsDTO = new LocationsDTO();

                    // Filter record count.
                    int recFilter = totalRecords;
                }
                //  return Json(new { data = lstLocationsDTO }, JsonRequestBehavior.AllowGet);
                return(View("AddorEdit", lstLocationsDTO));
            }
        }
Exemplo n.º 4
0
        public ActionResult AddOrEdit(LocationsDTO loc)
        {
            string msg = null;

            if (loc.ID == 0)
            {
                // Save location which are in Oacy/Unsc But not in location table
                var req = new RestRequest(string.Format("UpdateLocation"), Method.POST)
                {
                    RequestFormat = DataFormat.Json
                };
                req.JsonSerializer = NewtonsoftJsonSerializer.Default;
                req.AddJsonBody(loc);

                var response = clientLocation.Execute <bool>(req);
                msg = (response.Data ? "Saved Successfully" : "Something went Wrong!!");
            }
            else
            {
                // Update location in location table
                var request = new RestRequest(string.Format("UpdateLocation"), Method.POST)
                {
                    RequestFormat = DataFormat.Json
                };
                request.JsonSerializer = NewtonsoftJsonSerializer.Default;
                request.AddJsonBody(loc);
                var response = clientLocation.Execute <bool>(request);
                msg = (response.Data ? "Updated Successfully" : "Something went Wrong!!");
            }
            return(Json(new { success = true, message = msg }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public async Task <IResponse <List <PriceInquiryResult> > > PriceInquiry(LocationsDTO priceInquiry, bool cashed, bool hasReturn)
        {
            var result = new Response <List <PriceInquiryResult> >();

            result.Result = new List <PriceInquiryResult>();
            try
            {
                var peyk = await AloPeikProvider.PriceInquiry(priceInquiry.Source, priceInquiry.Destination, cashed, hasReturn);

                var post = await PostProvider.PriceInquiry(priceInquiry.Source, priceInquiry.Destination, cashed, hasReturn);

                if (peyk.IsNotNull())
                {
                    result.Result.Add(peyk);
                }
                if (post.IsNotNull())
                {
                    result.Result.Add(post);
                }
                result.IsSuccessful = true;
                result.Message      = ServiceMessage.Success;
                return(result);
            }
            catch (Exception e)
            {
                FileLoger.Error(e);

                result.Message = ServiceMessage.Exception;
                return(result);
            }
        }
Exemplo n.º 6
0
        public LocationsDTO Parse(Location item)
        {
            LocationsDTO result = new LocationsDTO();

            result.CreatedBy    = item.CreatedBy;
            result.ID           = item.ID;
            result.CreatedDate  = item.CreatedDate;
            result.Identifier   = item.Identifier;
            result.IsActive     = item.IsActive;
            result.ModifiedBy   = item.ModifiedBy;
            result.ModifiedDate = item.ModifiedDate;
            result.Name         = item.Name;
            result.PipelineID   = item.PipelineID;
            result.PropCode     = item.PropCode;
            result.RDUsageID    = item.RDUsageID;

            if (result.RDUsageID == 1)
            {
                result.RDB = "R";
            }
            else if (result.RDUsageID == 2)
            {
                result.RDB = "D";
            }
            else
            {
                result.RDB = "B";
            }

            return(result);
        }
Exemplo n.º 7
0
        public ActionResult AddLocation(FormCollection fc, LocationListDTO locList)
        {
            LocationsDTO        locationsDTO = new LocationsDTO();
            List <LocationsDTO> loc          = new List <LocationsDTO>();
            string pipelineDuns = fc["PipelineDuns"];

            loc            = locList.LocationsList.ToList();
            locList.DunsNo = pipelineDuns;
            ILocationService.AddLocationByPipeline(loc, pipelineDuns);
            return(RedirectToAction("Index", new { pipelineDuns = pipelineDuns }));
        }
Exemplo n.º 8
0
        public PartialViewResult AddLocationRow(string pipelineDuns, string RowCount)
        {
            LocationListDTO model = new LocationListDTO();

            model.CurrentLocationRow = Convert.ToInt32(RowCount);
            model.DunsNo             = pipelineDuns;
            model.LocationsList      = new List <LocationsDTO>();

            var item = new LocationsDTO();

            item.CreatedDate = DateTime.Now;
            model.LocationsList.Add(item);

            return(PartialView("_AddLocationRow", model));
        }
Exemplo n.º 9
0
        public List <LocationsDTO> GetLocations(string Keyword, string PipelineDuns)
        {
            List <LocationsDTO> resultantList = new List <LocationsDTO>();
            List <Location>     data          = new List <Location>();

            if (string.IsNullOrEmpty(Keyword))
            {
                data = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true).ToList();
            }
            else
            {
                data = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns &&
                                                a.IsActive == true &&
                                                (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).ToList();
            }

            foreach (var item in data)
            {
                var dtoObj = new LocationsDTO
                {
                    CreatedBy    = item.CreatedBy,
                    ID           = item.ID,
                    CreatedDate  = item.CreatedDate,
                    Identifier   = item.Identifier,
                    IsActive     = item.IsActive,
                    ModifiedBy   = item.ModifiedBy,
                    ModifiedDate = item.ModifiedDate,
                    Name         = item.Name,
                    PipelineID   = item.PipelineID,
                    PropCode     = item.PropCode,
                    RDUsageID    = item.RDUsageID,
                };
                if (dtoObj.RDUsageID == 1)
                {
                    dtoObj.RDB = "R";
                }
                else if (dtoObj.RDUsageID == 2)
                {
                    dtoObj.RDB = "D";
                }
                else
                {
                    dtoObj.RDB = "B";
                }
                resultantList.Add(dtoObj);
            }
            return(resultantList.OrderBy(a => a.Name).ToList());
        }
Exemplo n.º 10
0
        public ActionResult AddOrEdit(LocationsDTO loc)
        {
            string msg = null;

            if (loc.ID == 0)
            {
                bool Data = ILocationService.UpdateLocationByID(loc);
                msg = (Data ? "Saved Successfully" : "Something went Wrong!!");
            }
            else
            {
                bool Data = ILocationService.UpdateLocationByID(loc);
                msg = (Data ? "Updated Successfully" : "Something went Wrong!!");
            }
            return(Json(new { success = true, message = msg }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        public ActionResult AddLocation(FormCollection fc, LocationListDTO locList)
        {
            LocationsDTO        locationsDTO = new LocationsDTO();
            List <LocationsDTO> loc          = new List <LocationsDTO>();
            string PipelineDuns = fc["hdnPipelineDuns"];

            loc = locList.LocationsList.ToList();
            var request = new RestRequest(string.Format("AddLocation"), Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.JsonSerializer = NewtonsoftJsonSerializer.Default;
            request.AddJsonBody(loc);
            var    response = clientLocation.Execute <bool>(request);
            string pipeline = loc.Select(x => x.PipelineDuns).ToString();

            return(RedirectToAction("Index", new { pipelineDuns = pipeline }));
        }
Exemplo n.º 12
0
        public ActionResult Index(string pipelineDuns)
        {
            LocationsDTO            model = new LocationsDTO();
            ShipperReturnByIdentity currentIdentityValues = GetValueFromIdentity();

            PipelineDTO pipe = new PipelineDTO();

            if (Request["pipelineDuns"] == null || string.IsNullOrEmpty(pipelineDuns))
            {
                var pipes = GetPipelines();
                pipelineDuns = pipes.Count > 0 ? pipes.FirstOrDefault().DUNSNo : string.Empty;
            }
            else
            {
                pipelineDuns = Request["pipelineDuns"] != null ? Request["pipelineDuns"].ToString() : pipelineDuns;
            }
            model.PipelineDuns = pipelineDuns;
            return(View(model));
        }
Exemplo n.º 13
0
        public bool UpdateLocationByID(LocationsDTO loc)
        {
            // save location which are in Oacy/Unsc but not in table
            Location location = new Location();

            if (loc.ID == 0)
            {
                location.CreatedDate       = DateTime.Now;
                location.Name              = loc.Name;
                location.Identifier        = loc.Identifier;
                location.PropCode          = loc.PropCode;
                location.RDUsageID         = loc.RDUsageID;
                location.PipelineID        = loc.PipelineID;
                location.IsActive          = true;
                location.CreatedBy         = loc.CreatedBy;
                location.ModifiedBy        = loc.ModifiedBy;
                location.ModifiedDate      = DateTime.Now;
                location.PipeDuns          = loc.PipelineDuns;
                location.TransactionTypeId = 0;

                DbContext.Locations.Add(location);
                DbContext.SaveChanges();
            }
            else
            {
                //update location in location table
                var objLoc = DbContext.Locations.Where(a => a.ID == loc.ID).FirstOrDefault();
                objLoc.Name       = loc.Name;
                objLoc.Identifier = loc.Identifier;
                objLoc.PropCode   = loc.PropCode;
                objLoc.RDUsageID  = loc.RDUsageID;
                // objLoc.PipelineID = loc.PipelineID;
                // objLoc.IsActive = loc.IsActive;
                //objLoc.ModifiedBy = loc.ModifiedBy;
                objLoc.ModifiedDate = DateTime.Now;
                // objLoc.PipeDuns = loc.PipeDuns; // adding pipeduns is pending
                //objLoc.TransactionTypeId = 0;
                DbContext.Entry(objLoc).State = EntityState.Modified;
                DbContext.SaveChanges();
            }
            return(true);
        }
Exemplo n.º 14
0
        public LocationsDTO GetLocationById(int id)
        {
            LocationsDTO result = new LocationsDTO();

            Location data = new Location();

            if (id != 0)
            {
                data = DbContext.Locations.Where(a => a.ID == id).FirstOrDefault();
            }
            result.CreatedBy    = data.CreatedBy;
            result.ID           = data.ID;
            result.CreatedDate  = data.CreatedDate;
            result.Identifier   = data.Identifier;
            result.IsActive     = data.IsActive;
            result.ModifiedBy   = data.ModifiedBy;
            result.ModifiedDate = data.ModifiedDate;
            result.Name         = data.Name;
            result.PipelineID   = data.PipelineID;
            result.PropCode     = data.PropCode;
            result.RDUsageID    = data.RDUsageID;

            if (result.RDUsageID == 1)
            {
                result.RDB = "R";
            }
            else if (result.RDUsageID == 2)
            {
                result.RDB = "D";
            }
            else
            {
                result.RDB = "B";
            }

            return(result);
        }
Exemplo n.º 15
0
        // PageNo  = 0,1,2,3...so on.
        public List <LocationsDTO> GetLocationsWithPaging(string Keyword, string PipelineDuns, int PageNo, int PageSize, string PopupFor, bool IsSpecialDelCase, string order, string orderDir)
        {
            List <LocationsDTO> resultantList = new List <LocationsDTO>();
            List <Location>     Result        = new List <Location>();
            int NotRDB = 1; // for not Receipt locs.

            if (PopupFor == "RecLoc" || PopupFor == "Receipt" || PopupFor == "ContractPath" || PopupFor == "Supply")
            {
                NotRDB = 2;  // for not delivery locs.
                if (string.IsNullOrEmpty(Keyword))
                {
                    var QueryableData          = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB);
                    var QueryableDataWithOrder = GetQueryableDataWithOrder(QueryableData, order, orderDir);
                    Result = QueryableDataWithOrder.Skip(PageNo * PageSize).Take(PageSize).ToList();
                }
                else
                {
                    var QueryableDataWithKeyword = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns &&
                                                                            a.IsActive == true &&
                                                                            a.RDUsageID != NotRDB &&
                                                                            (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword)));
                    var QueryableDataWithOrder = GetQueryableDataWithOrder(QueryableDataWithKeyword, order, orderDir);
                    Result = QueryableDataWithOrder.Skip(PageNo * PageSize).Take(PageSize).ToList();
                }
            }
            else
            {
                NotRDB = 1;  // not-Receipt
                if (IsSpecialDelCase)
                {
                    if (PipelineDuns == "006958581")  // ANR Pipeline Company
                    {
                        // locationList = locationList.Where(a => a.PropCode == "103565" || a.PropCode == "103702").ToList();
                        if (string.IsNullOrEmpty(Keyword))
                        {
                            Result = DbContext.Location.Where(a => a.PropCode == "103565" || a.PropCode == "103702").OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                        else
                        {
                            Result = DbContext.Location.Where(a => (a.PropCode == "103565" || a.PropCode == "103702") &&
                                                              (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                    }
                    else if (PipelineDuns == "007933047") //Transwestern Pipeline Company, LLC
                    {
                        // locationList = locationList.Where(a => a.PropCode == "58646" || a.PropCode == "58647" || a.PropCode == "58648" || a.PropCode == "58649" || a.PropCode == "500543").ToList();
                        if (string.IsNullOrEmpty(Keyword))
                        {
                            Result = DbContext.Location.Where(a => a.PropCode == "58646" || a.PropCode == "58647" || a.PropCode == "58648" || a.PropCode == "58649" || a.PropCode == "500543").OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                        else
                        {
                            Result = DbContext.Location.Where(a => (a.PropCode == "58646" || a.PropCode == "58647" || a.PropCode == "58648" || a.PropCode == "58649" || a.PropCode == "500543") &&
                                                              (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                    }
                    else if (PipelineDuns == "829416002")  // FAYETTEVILLE EXPRESS PIPELINE LLC
                    {
                        //locationList = locationList.Where(a => a.PropCode == "58744").ToList();
                        if (string.IsNullOrEmpty(Keyword))
                        {
                            Result = DbContext.Location.Where(a => a.PropCode == "58744").OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                        else
                        {
                            Result = DbContext.Location.Where(a => (a.PropCode == "58744") &&
                                                              (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(Keyword))
                        {
                            Result = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB).OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                        else
                        {
                            Result = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns &&
                                                              a.IsActive == true &&
                                                              a.RDUsageID != NotRDB &&
                                                              (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword))).OrderBy(a => a.Name).Skip(PageNo * PageSize).Take(PageSize).ToList();
                        }
                    }
                }
                else//If location is Delivery
                {
                    if (string.IsNullOrEmpty(Keyword))
                    {
                        var QueriableDelLocData          = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns && a.IsActive == true && a.RDUsageID != NotRDB);
                        var QueryableDataWithOrderDelLoc = GetQueryableDataWithOrder(QueriableDelLocData, order, orderDir);
                        Result = QueryableDataWithOrderDelLoc.Skip(PageNo * PageSize).Take(PageSize).ToList();
                    }
                    else
                    {
                        var QueriableDelLocDataWithData = DbContext.Location.Where(a => a.PipeDuns == PipelineDuns &&
                                                                                   a.IsActive == true &&
                                                                                   a.RDUsageID != NotRDB &&
                                                                                   (a.Identifier.Contains(Keyword) || a.PropCode.Contains(Keyword) || a.Name.Contains(Keyword)));
                        var QueryableDataWithOrderDelLoc = GetQueryableDataWithOrder(QueriableDelLocDataWithData, order, orderDir);
                        Result = QueryableDataWithOrderDelLoc.Skip(PageNo * PageSize).Take(PageSize).ToList();
                    }
                }
            }


            foreach (var item in Result)
            {
                var dtoObj = new LocationsDTO
                {
                    CreatedBy    = item.CreatedBy,
                    ID           = item.ID,
                    CreatedDate  = item.CreatedDate,
                    Identifier   = item.Identifier,
                    IsActive     = item.IsActive,
                    ModifiedBy   = item.ModifiedBy,
                    ModifiedDate = item.ModifiedDate,
                    Name         = item.Name,
                    PipelineID   = item.PipelineID,
                    PropCode     = item.PropCode,
                    RDUsageID    = item.RDUsageID,
                };
                if (dtoObj.RDUsageID == 1)
                {
                    dtoObj.RDB = "R";
                }
                else if (dtoObj.RDUsageID == 2)
                {
                    dtoObj.RDB = "D";
                }
                else
                {
                    dtoObj.RDB = "B";
                }
                resultantList.Add(dtoObj);
            }
            return(resultantList);
        }
Exemplo n.º 16
0
        public bool UpdateLocationByID(LocationsDTO loc)
        {
            bool result = _ILocationRepository.UpdateLocationByID(modalFactory.Create(loc));

            return(result);
        }
Exemplo n.º 17
0
        public IHttpActionResult GetAllLocations()
        {
            List <LocationsDTO> res = LocationsDTO.ConvertToDto(DB.Locations.ToList());

            return(Ok(res));
        }
Exemplo n.º 18
0
 public async Task <IActionResult> Price([FromBody] LocationsDTO priceInquiry)
 => Ok(await _deliveryService.PriceInquiry(priceInquiry, false, false));
Exemplo n.º 19
0
        public IHttpActionResult SaveLocsNotInTblLoc([FromBody] LocationsDTO loc)
        {
            var source = locRepository.UpdateLocationByID(loc);

            return(Ok(source));
        }