public FrayteResult AddEditHSCodeSetting(eCommerceSettingModel HSCodeDetail)
        {
            FrayteResult FR     = new FrayteResult();
            HSCode       HSC    = new HSCode();
            var          Result = dbContext.HSCodes.Where(a => a.HSCodeId == HSCodeDetail.HsCodeId).FirstOrDefault();

            if (Result == null)
            {
                Mapper.CreateMap <eCommerceSettingModel, HSCode>();
                AutoMapper.Mapper.Map(HSCodeDetail, HSC);
                dbContext.HSCodes.Add(HSC);
                dbContext.SaveChanges();
                FR.Status = true;
            }
            else
            {
                Mapper.CreateMap <eCommerceSettingModel, HSCode>();
                AutoMapper.Mapper.Map(HSCodeDetail, Result);
                dbContext.Entry(Result).State = System.Data.Entity.EntityState.Modified;
                dbContext.SaveChanges();
                FR.Status = true;
            }

            return(FR);
        }
Exemplo n.º 2
0
        public FrayteResult SaveParcelHubKey(ParcelHubKeyModel ParcelHubKey)
        {
            FrayteResult result = new FrayteResult();
            APIKeyDetail parcelHubKey;

            if (ParcelHubKey.APIId == 0)
            {
                parcelHubKey         = new APIKeyDetail();
                parcelHubKey.APIKey  = ParcelHubKey.APIKey;
                parcelHubKey.APIName = ParcelHubKey.APIName;
                dbContext.APIKeyDetails.Add(parcelHubKey);
                dbContext.SaveChanges();
                result.Status = true;
            }
            else
            {
                parcelHubKey = dbContext.APIKeyDetails.Find(ParcelHubKey.APIId);
                if (parcelHubKey != null)
                {
                    parcelHubKey.APIKey  = ParcelHubKey.APIKey;
                    parcelHubKey.APIName = ParcelHubKey.APIName;
                    dbContext.SaveChanges();
                    result.Status = true;
                }
                else
                {
                    result.Status = false;
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public FrayteTimeZone SaveTimeZone(FrayteTimeZone timezone)
        {
            Timezone newTimeZone;

            if (timezone.TimezoneId > 0)
            {
                newTimeZone = dbContext.Timezones.Where(p => p.TimezoneId == timezone.TimezoneId).FirstOrDefault();

                newTimeZone.Name        = timezone.Name;
                newTimeZone.Offset      = timezone.Offset;
                newTimeZone.OffsetShort = timezone.OffsetShort;
            }
            else
            {
                newTimeZone             = new Timezone();
                newTimeZone.Name        = timezone.Name;
                newTimeZone.Offset      = timezone.Offset;
                newTimeZone.OffsetShort = timezone.OffsetShort;
                dbContext.Timezones.Add(newTimeZone);
            }

            dbContext.SaveChanges();

            timezone.TimezoneId = newTimeZone.TimezoneId;

            return(timezone);
        }
Exemplo n.º 4
0
        public FrayteResult AssignJobToOperator(OpeartorJob job)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                if (job != null && job.OperatorId > 0 && job.jobs != null && job.jobs.Count > 0)
                {
                    foreach (var data in job.jobs)
                    {
                        var ship = dbContext.eCommerceShipments.Find(data.ShipmentId);
                        if (ship != null)
                        {
                            ship.AssignedTo = job.OperatorId;
                            //dbContext.Entry<ship>
                            dbContext.SaveChanges();
                            result.Status = true;
                        }
                    }
                }
                else
                {
                    result.Status = false;
                }
                return(result);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                result.Status = false;
                return(result);
            }
        }
Exemplo n.º 5
0
        public int SaveMileStone(TrackingMileStoneModel TMSM)
        {
            var result          = dbContext.TrackingMileStones.Where(a => a.TrackingMileStoneId == TMSM.TrackingMileStoneId).FirstOrDefault();
            var ShipHandelCount = dbContext.TrackingMileStones.Where(a => a.ShipmentHandlerMethodId == TMSM.ShipmentHandlerMethodId).ToList();

            if (result == null)
            {
                TrackingMileStone TMS = new TrackingMileStone();
                TMS.MileStoneKey            = TMSM.MileStoneKey;
                TMS.Description             = TMSM.Description;
                TMS.OrderNumber             = TMSM.OrderNumber;
                TMS.ShipmentHandlerMethodId = TMSM.ShipmentHandlerMethodId;
                TMS.CreatedBy    = TMSM.CreatedBy;
                TMS.CreatedOnUtc = DateTime.UtcNow;
                TMS.UpdatedBy    = TMSM.UpdatedBy;
                TMS.UpdatedOnUtc = DateTime.UtcNow;
                dbContext.TrackingMileStones.Add(TMS);
                dbContext.SaveChanges();
                SetOrderAddEdit(TMS);
                return(TMS.TrackingMileStoneId);
            }
            else
            {
                result.MileStoneKey            = TMSM.MileStoneKey;
                result.Description             = TMSM.Description;
                result.OrderNumber             = TMSM.OrderNumber;
                result.ShipmentHandlerMethodId = TMSM.ShipmentHandlerMethodId;
                result.UpdatedBy              = TMSM.UpdatedBy;
                result.UpdatedOnUtc           = DateTime.UtcNow;
                dbContext.Entry(result).State = System.Data.Entity.EntityState.Modified;
                dbContext.SaveChanges();
                SetOrderAddEdit(result);
                return(result.TrackingMileStoneId);
            }
        }
Exemplo n.º 6
0
        public FrayteCarrier SaveCarrier(FrayteCarrier carrier)
        {
            Carrier newCarrier;

            if (carrier.CarrierId > 0)
            {
                newCarrier = dbContext.Carriers.Where(p => p.CarrierId == carrier.CarrierId).FirstOrDefault();

                newCarrier.CarrierName = carrier.CarrierName;
                newCarrier.Code        = carrier.Code;
                newCarrier.Prefix      = carrier.Prefix;
                newCarrier.CarrierType = carrier.CarrierType;
            }
            else
            {
                newCarrier             = new Carrier();
                newCarrier.CarrierId   = carrier.CarrierId;
                newCarrier.CarrierName = carrier.CarrierName;
                newCarrier.Code        = carrier.Code;
                newCarrier.Prefix      = carrier.Prefix;
                newCarrier.CarrierType = carrier.CarrierType;

                dbContext.Carriers.Add(newCarrier);
            }

            dbContext.SaveChanges();

            carrier.CarrierId = newCarrier.CarrierId;

            return(carrier);
        }
Exemplo n.º 7
0
        public FrayteResult DeleteSystemAlert(int systemAlertId)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                var systemAlert = dbContext.SystemAlerts.Find(systemAlertId);

                if (systemAlert != null)
                {
                    systemAlert.IsActive = false;
                    dbContext.Entry(systemAlert).State = System.Data.Entity.EntityState.Modified;
                    dbContext.SaveChanges();
                    result.Status = true;
                }
                else
                {
                    result.Status = false;
                }
            }
            catch (Exception ex)
            {
                result.Status = false;
            }

            return(result);
        }
        public FrayteResult UpdateRates(System.Data.DataTable exceldata)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                int k = 0;
                foreach (DataRow shipmentdetail in exceldata.Rows)
                {
                    if (k > 0)
                    {
                        for (int i = 0; i < exceldata.Columns.Count; i++)
                        {
                            var id       = exceldata.Columns[i].ColumnName;
                            var weightid = int.Parse(shipmentdetail.ItemArray[0].ToString());
                            if (i > 2)
                            {
                                var zoneid = int.Parse(id.ToString());
                                var dbRate = dbContext.LogisticServiceBaseRateCards.Where(p => p.LogisticServiceZoneId == zoneid && p.LogisticServiceWeightId == weightid).FirstOrDefault();
                                if (dbRate != null)
                                {
                                    dbRate.LogisticRate           = decimal.Parse(shipmentdetail.ItemArray[i].ToString());
                                    dbContext.Entry(dbRate).State = System.Data.Entity.EntityState.Modified;
                                    dbContext.SaveChanges();
                                }
                                else
                                {
                                    LogisticServiceBaseRateCard rate = new LogisticServiceBaseRateCard();
                                    rate.OperationZoneId                 = 2;
                                    rate.LogisticServiceZoneId           = zoneid;
                                    rate.LogisticServiceWeightId         = weightid;
                                    rate.LogisticServiceShipmentTypeId   = 48;
                                    rate.LogisticServiceDimensionId      = 0;
                                    rate.LogisticServiceCourierAccountId = 95;
                                    rate.LogisticRate     = decimal.Parse(shipmentdetail.ItemArray[i].ToString());
                                    rate.LogisticCurrency = "GBP";
                                    rate.ModuleType       = "DirectBooking";

                                    dbContext.LogisticServiceBaseRateCards.Add(rate);
                                    if (rate != null)
                                    {
                                        dbContext.SaveChanges();
                                    }
                                }
                            }
                        }
                    }
                    k++;
                }
                result.Status = true;
                return(result);
            }
            catch (Exception ex)
            {
                result.Status = false;
                return(result);
            }
        }
Exemplo n.º 9
0
 public void SaveEasyPostReceiverAddressId(int userAddressId, string easyPostAddressId)
 {
     try
     {
         var UserAddress = dbContext.UserAddresses.Find(userAddressId);
         UserAddress.EasyPostAddressId = easyPostAddressId;
         dbContext.SaveChanges();
     }
     catch (Exception e)
     {
     }
 }
Exemplo n.º 10
0
        public FrayteResult SetShipmentHSCode(int eCommerceShipmentDetailid, string HSCode)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                if (eCommerceShipmentDetailid > 0)
                {
                    var data = dbContext.eCommerceShipmentDetails.Find(eCommerceShipmentDetailid);
                    if (data != null)
                    {
                        data.HSCode = HSCode;
                        dbContext.Entry(data).State = System.Data.Entity.EntityState.Modified;
                        dbContext.SaveChanges();
                        result.Status = true;
                    }
                    else
                    {
                        result.Status = false;
                    }

                    try
                    {
                        var shipDetail = dbContext.eCommerceShipmentDetails
                                         .Where(p => p.eCommerceShipmentId == data.eCommerceShipmentId &&
                                                !string.IsNullOrEmpty(p.HSCode)).ToList();
                        if (shipDetail == null || (shipDetail != null || shipDetail.Count == 0))
                        {
                            var ship = dbContext.eCommerceShipments.Find(data.eCommerceShipmentId);
                            if (ship != null)
                            {
                                ship.MappedOn = DateTime.UtcNow;
                                dbContext.Entry(ship).State = System.Data.Entity.EntityState.Modified;
                                dbContext.SaveChanges();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                result.Status = false;
            }
            return(result);
        }
Exemplo n.º 11
0
        public TermAndCondition SaveTermAndCondition(TermAndCondition termAndCondition)
        {
            //For Term And Condition, we always have to create new term and condition in database.

            string shortCode             = string.Empty;
            var    customerCompanyDetail = dbContext.CustomerCompanyDetails.Where(p => p.UserId == termAndCondition.CreatedBy).FirstOrDefault();

            if (customerCompanyDetail != null)
            {
                shortCode = customerCompanyDetail.CompanyName.ToLower().Contains("mex") ? "MEX" : "";
            }

            var OperationZone = UtilityRepository.GetOperationZone();

            TermAndCondition newTermAndCondition = new TermAndCondition();

            newTermAndCondition.TermAndConditionId   = 0;
            newTermAndCondition.Detail               = termAndCondition.Detail;
            newTermAndCondition.CreatedOn            = DateTime.UtcNow;
            newTermAndCondition.OperationZoneId      = termAndCondition.OperationZoneId;
            newTermAndCondition.TermAndConditionType = termAndCondition.TermAndConditionType;
            newTermAndCondition.CreatedBy            = termAndCondition.CreatedBy;
            newTermAndCondition.ConpanyCode          = shortCode;
            dbContext.TermAndConditions.Add(newTermAndCondition);
            dbContext.SaveChanges();

            return(newTermAndCondition);
        }
Exemplo n.º 12
0
 public void EditThirPartyMatrix(List <FrayteThirdPartyMatrix> _party)
 {
     try
     {
         LogisticServiceThirdPartyMatrix tpm;
         if (_party != null && _party.Count > 0)
         {
             foreach (var pr in _party)
             {
                 tpm = dbContext.LogisticServiceThirdPartyMatrices.Where(x => x.LogisticServiceThirdPartyMatrixId == pr.ThirdPartyMatrixId).FirstOrDefault();
                 if (tpm != null)
                 {
                     tpm.FromLogisticServiceZoneId  = pr.FromZone.ZoneId;
                     tpm.ToLogisticServiceZoneId    = pr.ToZone.ZoneId;
                     tpm.ApplyLogisticServiceZoneId = pr.ApplyZone.ZoneId;
                     tpm.OperationZoneId            = pr.OperationZone.OperationZoneId;
                     dbContext.Entry(tpm).State     = System.Data.Entity.EntityState.Modified;
                     dbContext.SaveChanges();
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 13
0
 public void UpdateReportSettingDate(int CustomerPODSettingId, DateTime lastrun)
 {
     try
     {
         var rs = dbContext.CustomerSettings.Where(p => p.CustomerSettingId == CustomerPODSettingId).FirstOrDefault();
         if (rs != null && rs.CustomerSettingId > 0)
         {
             rs.UpdatedOn = lastrun;
             dbContext.Entry(rs).State = System.Data.Entity.EntityState.Modified;
             dbContext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 14
0
        public FrayteManifestName SaveLogisticServiceBaseRateHistory(int LogisticServiceId, int Year, string FileName)
        {
            FrayteManifestName name = new FrayteManifestName();

            try
            {
                LogisticServiceBaseRateCardHistory history = new LogisticServiceBaseRateCardHistory();
                history.LogisticServiceId = LogisticServiceId;
                history.ReportYear        = Year;
                history.ReportFileName    = FileName;
                dbContext.LogisticServiceBaseRateCardHistories.Add(history);
                dbContext.SaveChanges();

                //Retun Filename and Path
                name.FileName = FileName;
                name.FilePath = AppSettings.WebApiPath + "ReportFiles/BaseRateCard/" + FileName;
            }
            catch (DbEntityValidationException dbEx)
            {
                string validationErrorMsg = "";
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        validationErrorMsg = validationErrorMsg + string.Format("Property: {0} Error: {1}",
                                                                                validationError.PropertyName,
                                                                                validationError.ErrorMessage);
                    }
                }
            }
            return(name);
        }
Exemplo n.º 15
0
        public FrayteResult SaveManifestTracking(List <ManifestTrackingModel> MTM)
        {
            FrayteResult FR = new FrayteResult();

            try
            {
                foreach (var MT in MTM)
                {
                    var EMT = dbContext.eCommerceTrackings.Where(a => a.eCommerceShipmentId == MT.eCommerceShipmentId).FirstOrDefault();
                    if (EMT == null)
                    {
                        eCommerceTracking EMTNew = new eCommerceTracking();
                        EMTNew.eCommerceShipmentId     = MT.eCommerceShipmentId;
                        EMTNew.FrayteNumber            = MT.FrayteNo;
                        EMTNew.TrackingDescription     = MT.TrackingDescription;
                        EMTNew.TrackingMode            = MT.TrackingMode;
                        EMTNew.TrackingNumber          = MT.TrackingNo;
                        EMTNew.TrackingDescriptionCode = MT.TrackingDescriptionCode;
                        EMTNew.CreatedBy    = MT.CreatedBy;
                        EMTNew.CreatedOnUtc = MT.CreatedOnUtc;
                        EMTNew.CreatedBy    = MT.UserId;
                        dbContext.eCommerceTrackings.Add(EMTNew);
                        dbContext.SaveChanges();
                    }
                    else
                    {
                        EMT.eCommerceShipmentId     = MT.eCommerceShipmentId;
                        EMT.FrayteNumber            = MT.FrayteNo;
                        EMT.TrackingDescription     = MT.TrackingDescription;
                        EMT.TrackingMode            = MT.TrackingDescription;
                        EMT.TrackingNumber          = MT.TrackingNo;
                        EMT.TrackingDescriptionCode = MT.TrackingDescriptionCode;
                        EMT.CreatedBy              = MT.CreatedBy;
                        EMT.CreatedBy              = MT.UserId;
                        EMT.CreatedOnUtc           = MT.CreatedOnUtc;
                        dbContext.Entry(EMT).State = System.Data.Entity.EntityState.Modified;
                        dbContext.SaveChanges();
                    }
                }
                FR.Status = true;
            }
            catch (Exception e)
            {
                FR.Status = false;
            }
            return(FR);
        }
Exemplo n.º 16
0
 public void SaveConsignmentBag(FrayteConsignment cc)
 {
     try
     {
         ConsignmentBag cb;
         if (cc != null && cc.BagId == 0)
         {
             cb             = new ConsignmentBag();
             cb.Description = cc.Description;
             dbContext.ConsignmentBags.Add(cb);
             dbContext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 17
0
        public FrayteResult SaveShipperOtherAddress(FrayteAddress shipperOtherAddress)
        {
            FrayteResult result = new FrayteResult();

            UserAddress otherAddress = new UserAddress();

            if (shipperOtherAddress.UserAddressId > 0)
            {
                otherAddress = dbContext.UserAddresses.Find(shipperOtherAddress.UserAddressId);
                if (otherAddress != null)
                {
                    otherAddress.UserId    = shipperOtherAddress.UserId;
                    otherAddress.Address   = shipperOtherAddress.Address;
                    otherAddress.Address2  = shipperOtherAddress.Address2;
                    otherAddress.Address3  = shipperOtherAddress.Address3;
                    otherAddress.City      = shipperOtherAddress.City;
                    otherAddress.Suburb    = shipperOtherAddress.Suburb;
                    otherAddress.State     = shipperOtherAddress.State;
                    otherAddress.Zip       = shipperOtherAddress.Zip;
                    otherAddress.CountryId = shipperOtherAddress.Country.CountryId;

                    dbContext.SaveChanges();
                    result.Status = true;
                }
            }
            else
            {
                otherAddress.AddressTypeId = (int)FrayteAddressType.OtherAddress;
                otherAddress.UserId        = shipperOtherAddress.UserId;
                otherAddress.Address       = shipperOtherAddress.Address;
                otherAddress.Address2      = shipperOtherAddress.Address2;
                otherAddress.Address3      = shipperOtherAddress.Address3;
                otherAddress.City          = shipperOtherAddress.City;
                otherAddress.Suburb        = shipperOtherAddress.Suburb;
                otherAddress.State         = shipperOtherAddress.State;
                otherAddress.Zip           = shipperOtherAddress.Zip;
                otherAddress.CountryId     = shipperOtherAddress.Country.CountryId;

                dbContext.UserAddresses.Add(otherAddress);
                dbContext.SaveChanges();
                result.Status = true;
            }


            return(result);
        }
Exemplo n.º 18
0
        private void WorkingWeekDayDetails(int workingId, List <FrayteWorkingWeekDayDetail> frayteWorkingWeekDetail)
        {
            foreach (FrayteWorkingWeekDayDetail frayWeekDetail in frayteWorkingWeekDetail)
            {
                WorkingWeekDayDetail weekDetail = new WorkingWeekDayDetail();
                if (frayWeekDetail.WorkingWeekDayDetailId == 0)
                {
                    weekDetail.WorkingWeekDayId = workingId;
                    weekDetail.DayId            = frayWeekDetail.DayId;
                    weekDetail.DayName          = frayWeekDetail.DayName;
                    weekDetail.DayHalfTime      = frayWeekDetail.DayHalfTime;

                    dbContext.WorkingWeekDayDetails.Add(weekDetail);
                }
                else
                {
                    weekDetail = dbContext.WorkingWeekDayDetails.Where(p => p.WorkingWeekDayDetailId == frayWeekDetail.WorkingWeekDayDetailId).FirstOrDefault();
                    if (weekDetail != null)
                    {
                        weekDetail.WorkingWeekDayId = workingId;
                        weekDetail.DayId            = frayWeekDetail.DayId;
                        weekDetail.DayName          = frayWeekDetail.DayName;
                        weekDetail.DayHalfTime      = frayWeekDetail.DayHalfTime;
                    }
                }

                if (weekDetail != null)
                {
                    dbContext.SaveChanges();
                }

                frayWeekDetail.WorkingWeekDayDetailId = frayWeekDetail.WorkingWeekDayDetailId;
            }
        }
Exemplo n.º 19
0
        public FrayteResult SaveFuelSurCharge(FrayteFuelSurChargeSaveModel FrayteSurCharge)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                FrayteSurCharge.Year = new DateTime(FrayteSurCharge.Year.Year, 1, FrayteSurCharge.Year.Day);
                FuelSurCharge fuelsurcharge;

                var service = dbcontext.LogisticServices.Where(p => p.OperationZoneId == FrayteSurCharge.OperationZoneId && p.IsActive == true).ToList();
                if (service.Count > 0)
                {
                    foreach (var ss in service)
                    {
                        fuelsurcharge = new FuelSurCharge();
                        for (int i = 1; i <= 12; i++)
                        {
                            fuelsurcharge.OperationZoneId     = FrayteSurCharge.OperationZoneId;
                            fuelsurcharge.LogisticServiceId   = ss.LogisticServiceId;
                            fuelsurcharge.FrayteFuelPercent   = 0;
                            fuelsurcharge.ExpryesFuelPercent  = 0;
                            fuelsurcharge.DomesticFuelPercent = 0;
                            fuelsurcharge.RoadFuelSurcharge   = 0;
                            fuelsurcharge.FuelMonthYear       = FrayteSurCharge.Year;
                            fuelsurcharge.CreatedOn           = DateTime.UtcNow;
                            fuelsurcharge.UpdatedOn           = null;
                            fuelsurcharge.UpdatedBy           = 1;
                            fuelsurcharge.IsUpdated           = true;
                            dbcontext.FuelSurCharges.Add(fuelsurcharge);
                            dbcontext.SaveChanges();
                            FrayteSurCharge.Year = FrayteSurCharge.Year.AddMonths(1);
                        }
                    }
                }

                result.Status = true;
            }
            catch (Exception ex)
            {
                result.Status = false;
            }

            return(result);
        }
Exemplo n.º 20
0
        public FrayteResult SavePermissionToRole(AccessRoleModule accessRoleModule)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                if (accessRoleModule != null && accessRoleModule.ModuleLeveLId > 0)
                {
                    List <RoleModule> list = new List <RoleModule>();
                    if (accessRoleModule.UpdateCase == ModuleLevelUpdateCase.RoleModuleLevel)
                    {
                        list = dbContext.RoleModules.Where(p => p.ModuleLevelId == accessRoleModule.ModuleLeveLId && p.RoleId == accessRoleModule.RoleId).ToList();
                    }
                    else if (accessRoleModule.UpdateCase == ModuleLevelUpdateCase.RoleModuleDetailLevel)
                    {
                        list = dbContext.RoleModules.Where(p => p.ModuleLevelId == accessRoleModule.ModuleLeveLId && p.ModuleLevelDetailId == accessRoleModule.ModuleLeveLDetailId && p.RoleId == accessRoleModule.RoleId).ToList();
                    }
                    if (list != null && list.Count > 0)
                    {
                        foreach (var data in list)
                        {
                            data.IsActive = accessRoleModule.IsActive;
                            dbContext.Entry(data).State = System.Data.Entity.EntityState.Modified;
                            dbContext.SaveChanges();
                            result.Status = true;
                        }
                    }
                    else
                    {
                        result.Status = false;
                    }
                }
                else
                {
                    result.Status = false;
                }
            }
            catch (Exception ex)
            {
                result.Status = false;
            }
            return(result);
        }
Exemplo n.º 21
0
        public FrayteResult DeleteTradelaneShipment(int TradelaneShipmentId)
        {
            FrayteResult FE = new FrayteResult();

            FE.Status = false;
            var Result = dbContext.TradelaneShipments.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).FirstOrDefault();

            if (Result != null)
            {
                var FromAddress             = dbContext.TradelaneShipmentAddresses.Where(a => a.TradelaneShipmentAddressId == Result.FromAddressId).FirstOrDefault();
                var ToAddress               = dbContext.TradelaneShipmentAddresses.Where(a => a.TradelaneShipmentAddressId == Result.ToAddressId).FirstOrDefault();
                var TradelaneShipmentDetail = dbContext.TradelaneShipmentDetails.Where(a => a.TradelaneShipmentId == Result.TradelaneShipmentId).ToList();
                var TradelaneShipmentDoc    = dbContext.TradelaneShipmentDocuments.Where(a => a.TradelaneShipmentId == Result.TradelaneShipmentId).ToList();
                if (FromAddress != null)
                {
                    dbContext.TradelaneShipmentAddresses.Remove(FromAddress);
                    dbContext.SaveChanges();
                }
                if (ToAddress != null)
                {
                    dbContext.TradelaneShipmentAddresses.Remove(ToAddress);
                    dbContext.SaveChanges();
                }
                if (TradelaneShipmentDetail != null && TradelaneShipmentDetail.Count > 0)
                {
                    dbContext.TradelaneShipmentDetails.RemoveRange(TradelaneShipmentDetail);
                    dbContext.SaveChanges();
                }
                if (TradelaneShipmentDoc != null && TradelaneShipmentDoc.Count > 0)
                {
                    dbContext.TradelaneShipmentDocuments.RemoveRange(TradelaneShipmentDoc);
                    dbContext.SaveChanges();
                }
                dbContext.TradelaneShipments.Remove(Result);
                dbContext.SaveChanges();
                FE.Status = true;
                return(FE);
            }
            else
            {
                return(FE);
            }
        }
Exemplo n.º 22
0
 public FrayteTradelane SaveTradelane(FrayteTradelane frateTradelane)
 {
     try
     {
         Tradelane tradelane;
         if (frateTradelane.TradelaneId > 0)
         {
             tradelane = dbContext.Tradelanes.Where(p => p.TradelaneId == frateTradelane.TradelaneId).FirstOrDefault();
             tradelane.OriginatingAgentId   = frateTradelane.OriginatingAgent.UserId;
             tradelane.OriginCountryId      = frateTradelane.OriginatingCountry.CountryId;
             tradelane.DestinationAgentId   = frateTradelane.DestinationAgent.UserId;
             tradelane.DestinationCountryId = frateTradelane.DestinationCountry.CountryId;
             tradelane.Direct      = frateTradelane.Direct;
             tradelane.Deffered    = frateTradelane.Deffered;
             tradelane.CarrierId   = frateTradelane.Carrier.CarrierId;
             tradelane.TransitTime = frateTradelane.TransitTime;
             dbContext.SaveChanges();
             frateTradelane.TradelaneId = tradelane.TradelaneId;
         }
         else
         {
             tradelane = new Tradelane();
             tradelane.OriginatingAgentId   = frateTradelane.OriginatingAgent.UserId;
             tradelane.OriginCountryId      = frateTradelane.OriginatingCountry.CountryId;
             tradelane.DestinationAgentId   = frateTradelane.DestinationAgent.UserId;
             tradelane.DestinationCountryId = frateTradelane.DestinationCountry.CountryId;
             tradelane.Direct      = frateTradelane.Direct;
             tradelane.Deffered    = frateTradelane.Deffered;
             tradelane.CarrierId   = frateTradelane.Carrier.CarrierId;
             tradelane.TransitTime = frateTradelane.TransitTime;
             dbContext.Tradelanes.Add(tradelane);
             dbContext.SaveChanges();
             frateTradelane.TradelaneId = tradelane.TradelaneId;
         }
         return(frateTradelane);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 23
0
        public FrayteResult RemoveAssociateCustomer(int CustomerStaffDetailId)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                var detail = dbContext.CustomerStaffs.Where(p => p.CustomerStaffDetailId == CustomerStaffDetailId).FirstOrDefault();
                if (detail != null)
                {
                    detail.IsActive = false;
                    dbContext.Entry(detail).State = System.Data.Entity.EntityState.Modified;
                    dbContext.SaveChanges();
                    result.Status = true;
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.Status = false;
                return(result);
            }
        }
Exemplo n.º 24
0
        public FrayteCourier SaveCourier(FrayteCourier courier)
        {
            Courier newCourier;

            if (courier.CourierId > 0)
            {
                newCourier = dbContext.Couriers.Where(p => p.CourierId == courier.CourierId).FirstOrDefault();

                newCourier.CourierName       = courier.Name;
                newCourier.DisplayName       = CommonConversion.DisplayName(courier.Name);
                newCourier.Website           = courier.Website;
                newCourier.ShipmentType      = courier.CourierType;
                newCourier.LatestBookingTime = UtilityRepository.GetTimeFromString(courier.LatestBookingTime).Value;
            }
            else
            {
                newCourier                   = new Courier();
                newCourier.CourierId         = courier.CourierId;
                newCourier.CourierName       = courier.Name;
                newCourier.DisplayName       = CommonConversion.DisplayName(courier.Name);
                newCourier.Website           = courier.Website;
                newCourier.ShipmentType      = courier.CourierType;
                newCourier.LatestBookingTime = UtilityRepository.GetTimeFromString(courier.LatestBookingTime).Value;

                dbContext.Couriers.Add(newCourier);
            }

            try
            {
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
            }
            courier.CourierId = newCourier.CourierId;

            return(courier);
        }
Exemplo n.º 25
0
 public void SaveTracingComment(FrayteTracingComment ftc)
 {
     try
     {
         TracingComment tc;
         if (ftc != null && ftc.TracingCommentId == 0)
         {
             tc             = new TracingComment();
             tc.Description = ftc.Description;
             dbContext.TracingComments.Add(tc);
             dbContext.SaveChanges();
         }
         //else
         //{
         //    tc = dbContext.TracingComments.Find(ftc.TracingCommentId);
         //    tc.Description = ftc.Description;
         //    dbContext.TracingComments.Add(tc);
         //    dbContext.SaveChanges();
         //}
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 26
0
        public void UpdateOfflineTracking(List <FrayteOfflineTracking> frayteOfflineTracking)
        {
            if (frayteOfflineTracking != null && frayteOfflineTracking.Count > 0)
            {
                DirectShipmentTracking tracking;
                foreach (var item in frayteOfflineTracking)
                {
                    tracking = new DirectShipmentTracking();
                    tracking.DirectShipmentId    = item.ShipmentId;
                    tracking.CreatedOnUtc        = DateTime.UtcNow;
                    tracking.Location            = item.Location;
                    tracking.TrackingDescription = item.Message;

                    dbContext.DirectShipmentTrackings.Add(tracking);
                    dbContext.SaveChanges();
                }
            }
        }
Exemplo n.º 27
0
        //public SkyPostalResponseModel CreateShipment(SkyPostalRequestModel skyPostalRequest, int DirectShipmentDraftId)
        //{
        //    SkyPostalResponseModel respone = new SkyPostalResponseModel();
        //    var logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.SKYPOSTAL);
        //    string result = string.Empty;

        //    #region SKYPOSTaL API Login

        //    skyPostalRequest.Key = logisticIntegration.InetgrationKey;

        //    var skyPostalJson = Newtonsoft.Json.JsonConvert.SerializeObject(skyPostalRequest);

        //    result = SkyPostalWebApi(logisticIntegration, skyPostalJson);

        //    respone = Newtonsoft.Json.JsonConvert.DeserializeObject<SkyPostalResponseModel>(result);
        //    respone.Rawrequest = skyPostalJson;
        //    respone.Rawresponse = result;
        //    if (respone.success > 0)
        //    {
        //        return respone;
        //    }
        //    else
        //    {
        //        var j1 = JObject.Parse(result);

        //        var diff = j1["response"].ToList();

        //        respone.Error = new FratyteError();
        //        respone.Error.Service = new List<string>();
        //        string err = string.Empty;
        //        foreach (var error1 in diff)
        //        {
        //            err = error1.ToString();
        //            var err1 = err.Replace("{", "");
        //            var err2 = err1.Replace("}", "");

        //            respone.Error.Service.Add(err2);
        //        }

        //        respone.Error.Status = false;
        //        //Error Recorded
        //        SaveDirectShipmentObject(skyPostalJson, respone.Error.Service.ToString(), DirectShipmentDraftId);
        //        return respone;
        //    }
        //    #endregion
        //}

        private void SaveDirectShipmentObject(string ShipmetObject, string ShipmetErrorObject, int ShipmentDraftId)
        {
            try
            {
                var detail = dbContext.DirectShipmentDrafts.Find(ShipmentDraftId);
                if (detail != null)
                {
                    detail.EasyPostOrderObject    = ShipmetObject;
                    detail.EasyPostErrorObject    = ShipmetErrorObject;
                    detail.LastUpdated            = DateTime.UtcNow;
                    dbContext.Entry(detail).State = System.Data.Entity.EntityState.Modified;
                    dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(ShipmetObject));
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Exemplo n.º 28
0
        public FrayteResult DeleteCountryHoliday(int countryHolydayId)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                var publicHoliday = dbContext.CountryPublicHolidays.Find(countryHolydayId);
                if (publicHoliday != null)
                {
                    dbContext.CountryPublicHolidays.Remove(publicHoliday);
                    dbContext.SaveChanges();
                    result.Status = true;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.Status = false;
            }

            return(result);
        }
Exemplo n.º 29
0
        public FrayteResult SaveCustomerCharge(FrayteCustomerSpecificAdminCharges charge)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                AdminCharge adminCharge;
                foreach (var item in charge.Charges)
                {
                    if (item.AdminChargeId == 0)
                    {
                        adminCharge                 = new AdminCharge();
                        adminCharge.Value           = item.Amount;
                        adminCharge.CustomerId      = charge.CustomerId;
                        adminCharge.CreatedOnUtc    = DateTime.UtcNow;
                        adminCharge.IsActive        = true;
                        adminCharge.Name            = item.Value;
                        adminCharge.ShortName       = item.Key;
                        adminCharge.OperationZoneId = UtilityRepository.GetOperationZone().OperationZoneId;
                        adminCharge.ChargeType      = item.ChargeType;
                        adminCharge.CreatedBy       = item.CreatedBy;
                        adminCharge.CurrencyCode    = "GBP";// item.CurrencyCode;
                        dbcontext.AdminCharges.Add(adminCharge);
                        dbcontext.SaveChanges();
                    }
                    else
                    {
                        adminCharge              = dbcontext.AdminCharges.Find(item.AdminChargeId);
                        adminCharge.Value        = item.Amount;
                        adminCharge.UpdatedOnUtc = DateTime.UtcNow;
                        adminCharge.UpdatedBy    = item.CreatedBy;
                        dbcontext.SaveChanges();
                    }
                }
                result.Status = true;
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                result.Status = false;
            }
            return(result);
        }
Exemplo n.º 30
0
        public FrayteRateResponse SaveInitializeApiError(string Error)
        {
            FrayteRateResponse apierror = new FrayteRateResponse();

            if (Error != null && Error != "")
            {
                //Step 1.0 Get last record from apierrorcode table
                ApiErrorCode errordetail = dbContext.ApiErrorCodes.ToList().Last();
                if (errordetail != null)
                {
                    int errorcode = errordetail.ErrorCode.HasValue ? errordetail.ErrorCode.Value : 0;

                    apierror.Status      = false;
                    apierror.Description = null;
                    apierror.ShipmentId  = null;
                    apierror.RateCard    = null;

                    //Step 1.1 Checking same development error
                    List <ApiErrorCode> _error = dbContext.ApiErrorCodes.Where(p => p.DevelopmentErrorDetail == Error).ToList();
                    if (_error.Count > 0)
                    {
                        apierror.Errors = new List <FrayteApiError>();
                        {
                            foreach (ApiErrorCode ai in _error)
                            {
                                //Step 1.2 Make error response
                                FrayteApiError tt = new FrayteApiError()
                                {
                                    ErrorCode   = ai.ErrorCode.HasValue ? ai.ErrorCode.Value : 0,
                                    Description = ai.Description
                                };
                                apierror.Errors.Add(tt);
                            }
                        }
                    }
                    else
                    {
                        //Step 1.3 Insert error into apierrorcode table
                        ApiErrorCode code = new ApiErrorCode();
                        code.ErrorCode              = errorcode + 1;
                        code.Description            = Error;
                        code.DevelopmentErrorDetail = Error;
                        code.Courier                 = null;
                        code.CourierErrorCode        = null;
                        code.CourierErrorDescription = null;
                        code.ParentErrorCodeId       = errordetail.ErrorCodeId + 1;
                        if (code != null)
                        {
                            dbContext.ApiErrorCodes.Add(code);
                            dbContext.SaveChanges();
                        }

                        //Step 1.4 Make error response
                        apierror.Errors = new List <FrayteApiError>();
                        {
                            FrayteApiError tt = new FrayteApiError()
                            {
                                ErrorCode   = errorcode + 1,
                                Description = Error
                            };
                            apierror.Errors.Add(tt);
                        }
                    }
                }
            }
            return(apierror);
        }