Exemple #1
0
        public override async Task <IObjectModel> SelectByIDAsync(long id, long userId, CancellationToken cancellationToken)
        {
            DataTable dt;

            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add(DBObjects.SPParameter.ObjectId, GetParameter(DBObjects.SPParameter.ObjectId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, id));
            param.Add(DBObjects.SPParameter.UserId, GetParameter(DBObjects.SPParameter.UserId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, userId));
            dt = await this.GetSPDataTableAsync(DBObjects.StoredProcedures.pspObjectSelectById.ToString(), cancellationToken, param);

            IObjectModel model = new ObjectModel();

            model.ObjectId       = Convert.ToInt64(dt.Rows[0][DBObjects.Fields.ObjectId]);
            model.ModuleId       = Convert.ToInt64(dt.Rows[0][DBObjects.Fields.ModuleId]);
            model.Name           = dt.Rows[0][DBObjects.Fields.Name].ToString();
            model.Description    = PublicFunctions.ConvertNULL(dt.Rows[0][DBObjects.Fields.Description], "");
            model.Caption        = dt.Rows[0][DBObjects.Fields.Caption].ToString();
            model.URL            = Convert.ToString(PublicFunctions.ConvertDBNullToNull(dt.Rows[0][DBObjects.Fields.URL]));
            model.ParentObjectId = Convert.ToInt64(dt.Rows[0][DBObjects.Fields.ParentObjectId]);
            model.ObjectLevel    = Convert.ToInt32(dt.Rows[0][DBObjects.Fields.ObjectLevel]);
            model.AllowWrite     = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.AllowWrite]);
            model.AllowDelete    = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.AllowDelete]);
            model.IsActive       = Convert.ToBoolean(dt.Rows[0][DBObjects.Fields.IsActive]);
            model.ObjectOrder    = Convert.ToByte(PublicFunctions.ConvertDBNullToNull(dt.Rows[0][DBObjects.Fields.ObjectOrder]));
            model.ObjectImage    = PublicFunctions.ConvertNULL(dt.Rows[0][DBObjects.Fields.ObjectImage], "");
            return(model);
        }
Exemple #2
0
        public override async Task <IAdvertisementModel> SelectByIDAsync(Int64 id, Int64 userId, CancellationToken cancellationToken)
        {
            DataTable dt = null;
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add(DBObjects.SPParameter.AdvertisementId, GetParameter(DBObjects.SPParameter.AdvertisementId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, id));
            param.Add(DBObjects.SPParameter.UserId, GetParameter(DBObjects.SPParameter.UserId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, userId));
            dt = await this.GetSPDataTableAsync(DBObjects.StoredProcedures.hspAdvertisementSelectById.ToString(), cancellationToken, param);

            IAdvertisementModel model = new AdvertisementModel();

            model.AdvertisementId       = Convert.ToInt64(dt.Rows[0]["AdvertisementId"]);
            model.Name                  = PublicFunctions.ConvertNULL(dt.Rows[0]["Name"], "");
            model.Description           = PublicFunctions.ConvertNULL(dt.Rows[0]["Description"], "");
            model.CategoryName          = PublicFunctions.ConvertNULL(dt.Rows[0]["CategoryName"], "");
            model.IsMoreThanOne         = Convert.ToInt32(PublicFunctions.ConvertNULL(dt.Rows[0]["IsMoreThanOne"], false));
            model.Quantity              = PublicFunctions.ConvertNULL(dt.Rows[0]["Quantity"], (int)0);
            model.IsVisibleToPublic     = Convert.ToInt32(PublicFunctions.ConvertNULL(dt.Rows[0]["IsVisibleToPublic"], false));
            model.ChargingTypeId        = PublicFunctions.ConvertNULL(dt.Rows[0]["ChargingTypeId"], (long)0);
            model.DefaultTimeChargingId = PublicFunctions.ConvertNULL(dt.Rows[0]["DefaultTimeChargingId"], (long)0);
            model.MinimumCharges        = PublicFunctions.ConvertNULL(dt.Rows[0]["MinimumCharges"], (decimal)0.00);
            model.BondCharges           = PublicFunctions.ConvertNULL(dt.Rows[0]["BondCharges"], (decimal)0.00);
            model.DepositCharges        = PublicFunctions.ConvertNULL(dt.Rows[0]["DepositCharges"], (decimal)0.00);
            model.FixedRateCharges      = PublicFunctions.ConvertNULL(dt.Rows[0]["FixedRateCharges"], (decimal)0.00);
            model.FixedRateLabel        = PublicFunctions.ConvertNULL(dt.Rows[0]["FixedRateLabel"], "");
            model.SpecialTerms          = PublicFunctions.ConvertNULL(dt.Rows[0]["SpecialTerms"], "");
            model.VisibilityType        = PublicFunctions.ConvertNULL(dt.Rows[0]["VisibilityType"], (int)0);
            model.LocationId            = PublicFunctions.ConvertNULL(dt.Rows[0]["LocationId"], (long)0);
            model.AdvertiserId          = PublicFunctions.ConvertNULL(dt.Rows[0]["AdvertiserId"], (long)0);
            model.Email                 = PublicFunctions.ConvertNULL(dt.Rows[0]["Email"], "");
            model.Web              = PublicFunctions.ConvertNULL(dt.Rows[0]["Web"], "");
            model.PhoneNumber      = PublicFunctions.ConvertNULL(dt.Rows[0]["PhoneNumber"], "");
            model.Address          = PublicFunctions.ConvertNULL(dt.Rows[0]["Address"], "");
            model.AddDate          = PublicFunctions.ConvertNULL(dt.Rows[0]["AddDate"], DateTime.Now.AddYears(-100));
            model.ChargingDetail   = PublicFunctions.ConvertNULL(dt.Rows[0]["ChargingDetail"], "");
            model.ChargingTypeName = PublicFunctions.ConvertNULL(dt.Rows[0]["ChargingTypeName"], "");
            return(model);
        }
Exemple #3
0
        /// <summary>
        /// Custom rights implementation on Objects
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="objName"></param>
        /// <returns>AuthModel which defines Edit/Delete rights</returns>
        public AuthModel AuthorizeObject(long userId, string objName, string action)
        {
            DataTable dt;
            AuthModel model = null;
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add(DBObjects.SPParameter.UserId, GetParameter(DBObjects.SPParameter.UserId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, userId));
            param.Add(DBObjects.SPParameter.ObjectName, GetParameter(DBObjects.SPParameter.ObjectName, ParameterDirection.Input, ((int)SqlDbType.VarChar), 50, objName));

            dt = this.GetSPDataTable(DBObjects.StoredProcedures.pspAuthorization.ToString(), ref param);

            if (dt.Rows.Count > 0)
            {
                model                 = new AuthModel();
                model.AllowWrite      = PublicFunctions.ConvertNULL(dt.Rows[0]["AllowWrite"], false);
                model.AllowDelete     = PublicFunctions.ConvertNULL(dt.Rows[0]["AllowDelete"], false);
                model.ObjectName      = Convert.ToString(dt.Rows[0]["ObjectName"]);
                model.URL             = Convert.ToString(dt.Rows[0]["URL"]);
                model.IsWithoutSearch = PublicFunctions.ConvertNULL(dt.Rows[0]["IsWithoutSearch"], false);
                model.IsPublicUser    = Convert.ToBoolean(dt.Rows[0]["IsPublicUser"]);
            }

            return(model);
        }
Exemple #4
0
        public override async Task <long> SaveAsync(IAdvertisementModel model, CancellationToken cancellationToken)
        {
            Dictionary <string, object> param = new Dictionary <string, object>();

            string csIds = "", csPrices = "";

            if (model.TimePrices != null && model.TimePrices.Count > 0)
            {
                foreach (ValueId par in model.TimePrices)
                {
                    csIds    = csIds + par.Id + ",";
                    csPrices = csPrices + par.Price + ",";
                }
            }

            param.Add(DBObjects.SPParameter.Name, GetParameter(DBObjects.SPParameter.Name, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.Name.Length, PublicFunctions.ConvertNulltoDBNull(model.Name)));
            param.Add(DBObjects.SPParameter.Address, GetParameter(DBObjects.SPParameter.Address, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.Address.Length, PublicFunctions.ConvertNulltoDBNull(model.Address)));
            param.Add(DBObjects.SPParameter.PhoneNumber, GetParameter(DBObjects.SPParameter.PhoneNumber, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.PhoneNumber.Length, PublicFunctions.ConvertNulltoDBNull(model.PhoneNumber)));
            param.Add(DBObjects.SPParameter.Web, GetParameter(DBObjects.SPParameter.Web, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.Web.Length, PublicFunctions.ConvertNulltoDBNull(model.Web)));
            param.Add(DBObjects.SPParameter.Email, GetParameter(DBObjects.SPParameter.Email, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.Email.Length, PublicFunctions.ConvertNulltoDBNull(model.Email)));
            param.Add(DBObjects.SPParameter.AdvertiserId, GetParameter(DBObjects.SPParameter.AdvertiserId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, PublicFunctions.ConvertNulltoDBNull(model.AdvertiserId)));
            param.Add(DBObjects.SPParameter.CategoryId, GetParameter(DBObjects.SPParameter.CategoryId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, PublicFunctions.ConvertNulltoDBNull(model.CategoryIds[0])));
            param.Add(DBObjects.SPParameter.LocationId, GetParameter(DBObjects.SPParameter.LocationId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, PublicFunctions.ConvertNulltoDBNull(model.LocationId)));
            param.Add(DBObjects.SPParameter.VisibilityType, GetParameter(DBObjects.SPParameter.VisibilityType, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, PublicFunctions.ConvertNulltoDBNull(model.VisibilityType)));
            param.Add(DBObjects.SPParameter.SpecialTerms, GetParameter(DBObjects.SPParameter.SpecialTerms, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.SpecialTerms.Length, PublicFunctions.ConvertNulltoDBNull(model.SpecialTerms)));
            param.Add(DBObjects.SPParameter.FixedRateLabel, GetParameter(DBObjects.SPParameter.FixedRateLabel, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.FixedRateLabel.Length, PublicFunctions.ConvertNulltoDBNull(model.FixedRateLabel)));
            param.Add(DBObjects.SPParameter.FixedRateCharges, GetParameter(DBObjects.SPParameter.FixedRateCharges, ParameterDirection.Input, ((int)SqlDbType.Decimal), 16, PublicFunctions.ConvertNulltoDBNull(model.FixedRateCharges)));
            param.Add(DBObjects.SPParameter.DepositCharges, GetParameter(DBObjects.SPParameter.DepositCharges, ParameterDirection.Input, ((int)SqlDbType.Decimal), 16, PublicFunctions.ConvertNULL(model.DepositCharges, (Decimal)0)));
            param.Add(DBObjects.SPParameter.BondCharges, GetParameter(DBObjects.SPParameter.BondCharges, ParameterDirection.Input, ((int)SqlDbType.Decimal), 16, PublicFunctions.ConvertNULL(model.BondCharges, (Decimal)0)));
            param.Add(DBObjects.SPParameter.MinimumCharges, GetParameter(DBObjects.SPParameter.MinimumCharges, ParameterDirection.Input, ((int)SqlDbType.Decimal), 16, PublicFunctions.ConvertNULL(model.MinimumCharges, (Decimal)0)));
            param.Add(DBObjects.SPParameter.DefaultTimeChargingId, GetParameter(DBObjects.SPParameter.DefaultTimeChargingId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 16, PublicFunctions.ConvertNulltoDBNull(model.DefaultTimeChargingId)));
            param.Add(DBObjects.SPParameter.ChargingTypeId, GetParameter(DBObjects.SPParameter.ChargingTypeId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 16, PublicFunctions.ConvertNulltoDBNull(model.ChargingTypeId)));
            param.Add(DBObjects.SPParameter.IsVisibleToPublic, GetParameter(DBObjects.SPParameter.IsVisibleToPublic, ParameterDirection.Input, ((int)SqlDbType.Bit), 4, PublicFunctions.ConvertNulltoDBNull(Convert.ToBoolean(model.IsVisibleToPublic))));
            param.Add(DBObjects.SPParameter.Quantity, GetParameter(DBObjects.SPParameter.Quantity, ParameterDirection.Input, ((int)SqlDbType.Int), 16, PublicFunctions.ConvertNulltoDBNull(model.Quantity)));
            param.Add(DBObjects.SPParameter.IsMoreThanOne, GetParameter(DBObjects.SPParameter.IsMoreThanOne, ParameterDirection.Input, ((int)SqlDbType.Bit), 4, PublicFunctions.ConvertNulltoDBNull(Convert.ToBoolean(model.IsMoreThanOne))));
            param.Add(DBObjects.SPParameter.Description, GetParameter(DBObjects.SPParameter.Description, ParameterDirection.Input, ((int)SqlDbType.NVarChar), model.Description.Length, PublicFunctions.ConvertNulltoDBNull(model.Description)));
            param.Add(DBObjects.SPParameter.IdList, GetParameter(DBObjects.SPParameter.IdList, ParameterDirection.Input, ((int)SqlDbType.NVarChar), csIds.Length, PublicFunctions.ConvertNulltoDBNull(csIds)));

            param.Add(DBObjects.SPParameter.PriceList, GetParameter(DBObjects.SPParameter.PriceList, ParameterDirection.Input, ((int)SqlDbType.NVarChar), csPrices.Length, PublicFunctions.ConvertNulltoDBNull(csPrices)));
            param.Add(DBObjects.SPParameter.AddUserId, GetParameter(DBObjects.SPParameter.AddUserId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, model.UserId));
            param.Add(DBObjects.SPParameter.AdvertisementId, GetParameter(DBObjects.SPParameter.AdvertisementId, ParameterDirection.Output, ((int)SqlDbType.BigInt), 8, 0));
            param.Add(DBObjects.SPParameter.RetVal, GetParameter(DBObjects.SPParameter.RetVal, ParameterDirection.Output, ((int)SqlDbType.Int), 4, 0));

            await this.ExecuteSPAsync(DBObjects.StoredProcedures.hspAdvertisementSave.ToString(), cancellationToken, param);

            return(Convert.ToInt64(((SqlParameter)param[DBObjects.SPParameter.RetVal]).Value));
        }