Пример #1
0
        public bool Delete(HouseOption house, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_HouseOptionDeleteByHouseId");
            db.AddInParameter(command, "HouseId", DbType.Guid, house.HouseId);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }
            return true;
        }
Пример #2
0
        public bool Delete(HouseOption house, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_HouseOptionDeleteByHouseId");

            db.AddInParameter(command, "HouseId", DbType.Guid, house.HouseId);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }
            return(true);
        }
Пример #3
0
        public bool Select(House entity)
        {
            bool result = true;

            Database  db        = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbCommand dbCommand = db.GetStoredProcCommand("usp_HouseSelect");

            db.AddInParameter(dbCommand, "HouseId", DbType.Guid, entity.HouseId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    if (entity == null)
                    {
                        entity = new House();
                    }
                    RHP.Utility.Generic.AssignDataReaderToEntity(dataReader, entity);
                }

                if (dataReader.NextResult())
                {
                    while (dataReader.Read())
                    {
                        HouseOption houseOption = new HouseOption();
                        RHP.Utility.Generic.AssignDataReaderToEntity(dataReader, houseOption);
                        if (entity.HouseOptionList == null)
                        {
                            entity.HouseOptionList = new List <HouseOption>();
                        }
                        entity.HouseOptionList.Add(houseOption);
                    }
                }
            }

            if (entity.HouseOptionList != null)
            {
                foreach (HouseOption houseOption in entity.HouseOptionList)
                {
                    Option option = RHP.Utility.Generic.Get <Option>(houseOption.OptionId);
                    houseOption.Option = option;
                }
            }
            return(result);
        }
Пример #4
0
        public bool Insert(HouseOption option, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_HouseOptionInsert");

            db.AddInParameter(command, "HouseId", DbType.Guid, option.HouseId);
            db.AddInParameter(command, "OptionId", DbType.Int32, option.OptionId);
            db.AddInParameter(command, "OptionValue", DbType.String, option.OptionValue);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, option.CreatedBy);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            return true;
        }
Пример #5
0
        public bool Insert(HouseOption option, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_HouseOptionInsert");

            db.AddInParameter(command, "HouseId", DbType.Guid, option.HouseId);
            db.AddInParameter(command, "OptionId", DbType.Int32, option.OptionId);
            db.AddInParameter(command, "OptionValue", DbType.String, option.OptionValue);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, option.CreatedBy);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            return(true);
        }
Пример #6
0
        public bool Select(House entity)
        {
            bool result = true;

               Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
               DbCommand dbCommand = db.GetStoredProcCommand("usp_HouseSelect");

               db.AddInParameter(dbCommand, "HouseId", DbType.Guid, entity.HouseId);

               using (IDataReader dataReader = db.ExecuteReader(dbCommand))
               {
               if (dataReader.Read())
               {
                   if (entity == null)
                   {
                       entity = new House();
                   }
                   RHP.Utility.Generic.AssignDataReaderToEntity(dataReader, entity);
               }

               if (dataReader.NextResult())
               {
                   while (dataReader.Read())
                   {
                       HouseOption houseOption = new HouseOption();
                       RHP.Utility.Generic.AssignDataReaderToEntity(dataReader, houseOption);
                       if (entity.HouseOptionList == null)
                       {
                           entity.HouseOptionList = new List<HouseOption>();
                       }
                       entity.HouseOptionList.Add(houseOption);
                   }
               }
               }

               if (entity.HouseOptionList != null)
               {
               foreach (HouseOption houseOption in entity.HouseOptionList)
               {
                   Option option = RHP.Utility.Generic.Get<Option>(houseOption.OptionId);
                   houseOption.Option = option;
               }

               }
               return result;
        }
Пример #7
0
        public void AddPropertyInfo()
        {
            house = House.Select(HouseId);
            if (house == null)
                house = new House();

            if (house.HouseOptionList == null)
            {
                house.HouseOptionList = new List<HouseOption>();
            }
            else
            {
                house.HouseOptionList.Clear();
            }
             // house.HouseOptionList.Clear();
            foreach (ListItem item in chkOptionList.Items)
            {
                if (item.Selected)
                {
                    HouseOption option = new HouseOption();
                    option.HouseId = house.HouseId.Value;
                    option.OptionId = int.Parse(item.Value);
                    house.HouseOptionList.Add(option);
                }

            }

            foreach (ListItem item in chkFurnishedroomoptions.Items)
            {
                if (item.Selected)
                {
                    HouseOption option = new HouseOption();
                    option.HouseId = house.HouseId.Value;
                    option.OptionId = int.Parse(item.Value);
                    house.HouseOptionList.Add(option);
                }
            }

            foreach (ListItem item in chkFurnishedlivingspaceOptions.Items)
            {
                if (item.Selected)
                {
                    HouseOption option = new HouseOption();
                    option.HouseId = house.HouseId.Value;
                    option.OptionId = int.Parse(item.Value);
                    house.HouseOptionList.Add(option);
                }
            }

            foreach (ListItem item in chkFurnishedkitchenOptions.Items)
            {
                if (item.Selected)
                {
                    HouseOption option = new HouseOption();
                    option.HouseId = house.HouseId.Value;
                    option.OptionId = int.Parse(item.Value);
                    house.HouseOptionList.Add(option);
                }
            }

            if (houseOption.Save(house))
            {

            }
        }