public NRestResult <List <UserCreditBalance> > GetActiveUserCreditBalances(TSB value)
            {
                NRestResult <List <UserCreditBalance> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <UserCreditBalance> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <List <UserCreditBalance> >(
                        RouteConsts.Credit.GetActiveUserCreditBalances.Url, value);
                }
                else
                {
                    ret = new NRestResult <List <UserCreditBalance> >();
                    ret.ParameterIsNull();
                    ret.data = new List <UserCreditBalance>();
                }
                return(ret);
            }
            public NRestResult <List <TSBCreditTransaction> > GetReplaceTSBCreditTransaction(DateTime value)
            {
                NRestResult <List <TSBCreditTransaction> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <TSBCreditTransaction> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <List <TSBCreditTransaction> >(
                        RouteConsts.Credit.GetReplaceTSBCreditTransaction.Url, value);
                }
                else
                {
                    ret = new NRestResult <List <TSBCreditTransaction> >();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <UserCreditBalance> SaveUserCreditBalance(UserCreditBalance value)
            {
                NRestResult <UserCreditBalance> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <UserCreditBalance>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <UserCreditBalance>(
                        RouteConsts.Credit.SaveUserCreditBalance.Url, value);
                }
                else
                {
                    ret = new NRestResult <UserCreditBalance>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <UserCreditBalance> GetNoRevenueEntryUserCreditBalanceById(
                Search.UserCredits.GetActiveById value)
            {
                NRestResult <UserCreditBalance> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <UserCreditBalance>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <UserCreditBalance>(
                        RouteConsts.Credit.GetNoRevenueEntryUserCreditBalanceById.Url, value);
                }
                else
                {
                    ret = new NRestResult <UserCreditBalance>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <TSBCouponBalance> GetTSBBalance(TSB value)
            {
                NRestResult <TSBCouponBalance> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <TSBCouponBalance>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <TSBCouponBalance>(
                        RouteConsts.Coupon.GetTSBBalance.Url, value);
                }
                else
                {
                    ret = new NRestResult <TSBCouponBalance>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <TSBCouponTransaction> SaveTransaction(TSBCouponTransaction value)
            {
                NRestResult <TSBCouponTransaction> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <TSBCouponTransaction>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <TSBCouponTransaction>(
                        RouteConsts.Coupon.SaveTSBCouponTransaction.Url, value);
                }
                else
                {
                    ret = new NRestResult <TSBCouponTransaction>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <List <LanePayment> > GetPaymentsByUserShift(
                Search.Lanes.Attendances.ByUserShift value)
            {
                NRestResult <List <LanePayment> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <LanePayment> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <List <LanePayment> >(
                        RouteConsts.Lane.GetPaymentsByUserShift.Url, value);
                }
                else
                {
                    ret = new NRestResult <List <LanePayment> >();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
            public NRestResult <LanePayment> GetCurrentPaymentsByLane(
                Search.Lanes.Current.PaymentByLane value)
            {
                NRestResult <LanePayment> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <LanePayment>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <LanePayment>(
                        RouteConsts.Lane.GetCurrentPaymentsByLane.Url, value);
                }
                else
                {
                    ret = new NRestResult <LanePayment>();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
            public NRestResult <List <TSBCouponSummary> > GetTSBCouponSummaries(TSB value)
            {
                NRestResult <List <TSBCouponSummary> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <TSBCouponSummary> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <List <TSBCouponSummary> >(
                        RouteConsts.Coupon.GetTSBCouponSummaries.Url, value);
                }
                else
                {
                    ret = new NRestResult <List <TSBCouponSummary> >();
                    ret.ParameterIsNull();
                    ret.data = new List <TSBCouponSummary>();
                }
                return(ret);
            }
            public NRestResult <LanePayment> CreatePayment(Lane lane, User supervisor,
                                                           Payment payment, DateTime date, decimal amount)
            {
                NRestResult <LanePayment> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <LanePayment>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                ret = client.Execute <LanePayment>(
                    RouteConsts.Lane.CreatePayment.Url,
                    new LanePaymentCreate()
                {
                    Lane    = lane,
                    User    = supervisor,
                    Payment = payment,
                    Date    = date,
                    Amount  = amount
                });
                return(ret);
            }
            public NRestResult <List <LaneAttendance> > GetAttendancesByRevenue(
                RevenueEntry value)
            {
                NRestResult <List <LaneAttendance> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <LaneAttendance> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <List <LaneAttendance> >(
                        RouteConsts.Lane.GetAttendancesByRevenue.Url, value);
                }
                else
                {
                    ret = new NRestResult <List <LaneAttendance> >();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
            public NRestResult <UserShift> GetCurrent(User value)
            {
                NRestResult <UserShift> ret;
                NRestClient             client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <UserShift>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <UserShift>(
                        RouteConsts.UserShift.GetCurrent.Url, value);
                }
                else
                {
                    ret = new NRestResult <UserShift>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <List <TAServerCouponTransaction> > GetTAServerCouponTransactions(
                string tsbId, string userId, int?transactionType, int?couponType)
            {
                NRestResult <List <TAServerCouponTransaction> > ret;
                NRestClient client = NRestClient.CreateTAxTODClient();

                if (null == client)
                {
                    ret = new NRestResult <List <TAServerCouponTransaction> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                var url   = "api/users/coupons/getlist";
                var value = new
                {
                    tsbid           = tsbId,
                    userid          = userId,
                    transactiontype = transactionType,
                    coupontype      = couponType
                };

                if (null != value)
                {
                    ret = client.Execute <List <TAServerCouponTransaction> >(url, value);
                }
                else
                {
                    ret = new NRestResult <List <TAServerCouponTransaction> >();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
            public NRestResult <TSBExchangeTransaction> GetTSBExchangeTransaction(
                Search.Exchanges.Transactions.Filter value)
            {
                NRestResult <TSBExchangeTransaction> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <TSBExchangeTransaction>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <TSBExchangeTransaction>(
                        RouteConsts.Exchange.GetTSBExchangeTransaction.Url, value);
                }
                else
                {
                    ret = new NRestResult <TSBExchangeTransaction>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
            public NRestResult <TSBExchangeGroup> SaveTSBExchangeGroup(
                TSBExchangeGroup value)
            {
                NRestResult <TSBExchangeGroup> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <TSBExchangeGroup>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <TSBExchangeGroup>(
                        RouteConsts.Exchange.SaveTSBExchangeGroup.Url, value);
                }
                else
                {
                    ret = new NRestResult <TSBExchangeGroup>();
                    ret.ParameterIsNull();
                    ret.data = null;
                }
                return(ret);
            }
示例#16
0
        public static T Value <T>(this NRestResult <T> value)
            where T : new()
        {
            T ret = (null != value && !value.errors.hasError && null != value.data) ?
                    value.data : DefaultData <T>();

            return(ret);
        }
示例#17
0
        public static O Output <T, O>(this NRestResult <T, O> value)
            where T : new()
            where O : new()
        {
            O ret = (null != value && !value.errors.hasError && null != value.output) ?
                    value.output : DefaultOutput <O>();

            return(ret);
        }
示例#18
0
            public NRestResult <List <Shift> > GetShifts()
            {
                NRestResult <List <Shift> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <Shift> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                ret = client.Execute <List <Shift> >(RouteConsts.Shift.GetShifts.Url, new { });
                return(ret);
            }
示例#19
0
            public NRestResult <TSB> GetCurrent()
            {
                NRestResult <TSB> ret;
                NRestClient       client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <TSB>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                ret = client.Execute <TSB>(RouteConsts.TSB.GetCurrent.Url, new { });
                return(ret);
            }
            public NRestResult <List <MCurrency> > GetCurrencies()
            {
                NRestResult <List <MCurrency> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <MCurrency> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                ret = client.Execute <List <MCurrency> >(
                    RouteConsts.Master.GetCurrencies.Url, new { });
                return(ret);
            }
            public NRestResult SaveMCurrencies(List <MCurrency> values)
            {
                NRestResult ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                ret = client.Execute(
                    RouteConsts.Master.SaveMCurrencies.Url, values);
                return(ret);
            }
            public NRestResult <List <LaneAttendance> > GetAllNotHasRevenueEntryByUser(User value)
            {
                NRestResult <List <LaneAttendance> > ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <List <LaneAttendance> >();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                ret = client.Execute <List <LaneAttendance> >(
                    RouteConsts.Lane.GetAllNotHasRevenueEntryByUser.Url, value);
                return(ret);
            }
示例#23
0
        public static NRestResult ToRest(this NDbResult value)
        {
            NRestResult ret = new NRestResult();

            if (null != value)
            {
                ret.errors.errNum = value.errors.errNum;
                ret.errors.errMsg = value.errors.errMsg;
            }
            else
            {
                ret.ParameterIsNull();
            }

            return(ret);
        }
示例#24
0
        public static NRestResult <T> ToRest <T>(this NDbResult <T> value)
            where T : new()
        {
            NRestResult <T> ret = new NRestResult <T>();

            if (null != value)
            {
                ret.data          = value.data;
                ret.errors.errNum = value.errors.errNum;
                ret.errors.errMsg = value.errors.errMsg;
            }
            else
            {
                ret.ParameterIsNull();
            }

            return(ret);
        }
            public NRestResult <LaneAttendance> CreateAttendance(Lane lane, User supervisor)
            {
                NRestResult <LaneAttendance> ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <LaneAttendance>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                ret = client.Execute <LaneAttendance>(RouteConsts.Lane.CreateAttendance.Url,
                                                      new LaneAttendanceCreate()
                {
                    Lane = lane,
                    User = supervisor
                });
                return(ret);
            }
            public NRestResult SaveTransaction(TAServerCouponTransaction value)
            {
                NRestResult ret;
                NRestClient client = NRestClient.CreateTAxTODClient();

                if (null == client)
                {
                    ret = new NRestResult();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                var url = "api/users/coupons/save";

                if (null != value)
                {
                    var inst = new
                    {
                        couponpk        = value.CouponPK,
                        transactiondate = value.TransactionDate,
                        //transactionid = value.TransactionId,
                        tsbid           = value.TSBId,
                        coupontype      = value.CouponType,
                        serialno        = value.SerialNo,
                        price           = value.Price,
                        userid          = value.UserId,
                        userreceivedate = value.UserReceiveDate,
                        Couponstatus    = value.CouponStatus,
                        solddate        = value.SoldDate,
                        soldby          = value.SoldBy,
                        finishflag      = value.FinishFlag
                    };
                    ret = client.Execute <List <TAServerCouponTransaction> >(url, inst);
                }
                else
                {
                    ret = new NRestResult();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
            public NRestResult <UserShift> Create(Shift shift, User collector)
            {
                NRestResult <UserShift> ret;
                NRestClient             client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <UserShift>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                var inst = new UserShiftCreate()
                {
                    Shift = shift,
                    User  = collector
                };

                ret = client.Execute <UserShift>(RouteConsts.UserShift.Create.Url, inst);
                return(ret);
            }
            public NRestResult <Role> GetRole(Search.Roles.ById value)
            {
                NRestResult <Role> ret;
                NRestClient        client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <Role>();
                    ret.RestInvalidConfig();
                    return(ret);
                }
                if (null != value)
                {
                    ret = client.Execute <Role>(RouteConsts.User.GetRole.Url, value);
                }
                else
                {
                    ret = new NRestResult <Role>();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
示例#29
0
            public NRestResult ChangeShift(TSBShift value, List <Plaza> plazas)
            {
                NRestResult ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    // set date
                    value.Begin = DateTime.Now;
                    ret         = client.Execute(RouteConsts.Shift.ChangeShift.Url, value);
                    if (ret.Ok && null != plazas && plazas.Count > 0)
                    {
                        // send to server
                        SCWOperations server = SCWServiceOperations.Instance.Plaza;
                        var           inst   = new SCWChiefOfDuty();
                        inst.networkId     = 31; // TODO: network id required.
                        inst.plazaId       = Convert.ToInt32(plazas[0].SCWPlazaId);
                        inst.staffId       = value.UserId;
                        inst.staffTypeId   = 1;
                        inst.beginDateTime = value.Begin;
                        // send.
                        server.TOD.SaveChiefOfDuty(inst);
                    }
                }
                else
                {
                    ret = new NRestResult();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
            public NRestResult <User> SaveUser(User value)
            {
                NRestResult <User> ret;
                NRestClient        client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult <User>();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    ret = client.Execute <User>(RouteConsts.User.SaveUser.Url, value);
                }
                else
                {
                    ret = new NRestResult <User>();
                    ret.ParameterIsNull();
                }
                return(ret);
            }