public bool Save(House house) { bool result = false; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { HouseDAO houseDAO = new HouseDAO(); // House house = new House(); if (houseDAO.IsHouseExist(house)) { result = new HouseOptionDAO().Delete(new HouseOption() { HouseId = house.HouseId.Value }, db, transaction); if (house.HouseOptionList != null) { foreach (HouseOption item in house.HouseOptionList) { new HouseOptionDAO().Insert(item, db, transaction); } } } if (result) { transaction.Commit(); } else { transaction.Rollback(); } } catch (System.Exception ex) { transaction.Rollback(); result = false; throw ex; } finally { connection.Close(); } return result; }
public bool Delete(House house, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_HouseDelete"); db.AddInParameter(command, "HouseId", DbType.Guid, house.HouseId); db.AddInParameter(command, "UpdatedBy", DbType.Guid, house.UpdatedBy); if (transaction == null) { db.ExecuteNonQuery(command); } else { db.ExecuteNonQuery(command, transaction); } return true; }
public bool Insert(House house, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_HouseInsert"); house.HouseId = Guid.NewGuid(); db.AddInParameter(command, "HouseId", DbType.Guid, house.HouseId); db.AddInParameter(command, "LandlordId", DbType.Guid, house.LandlordId); db.AddInParameter(command, "StreetAddress", DbType.String, house.StreetAddress); db.AddInParameter(command, "City", DbType.String, house.City); db.AddInParameter(command, "StateId", DbType.Int32, house.StateId); db.AddInParameter(command, "Zip", DbType.String, house.Zip); db.AddInParameter(command, "YearHomeBuild", DbType.Int16, house.YearHomeBuild); db.AddInParameter(command, "BedRooms", DbType.Int16, house.BathRooms); db.AddInParameter(command, "BathRooms", DbType.Int16, house.BedRooms); db.AddInParameter(command, "LotSquareFootage", DbType.Int32, house.LotSquareFootage); db.AddInParameter(command, "TotalSquareFootage", DbType.Int32, house.TotalSquareFootage); db.AddInParameter(command, "UtilitiesIncludedInRent", DbType.String, house.UtilitiesIncludedInRent); db.AddInParameter(command, "PropertyImagePath", DbType.String, house.PropertyImagePath); db.AddInParameter(command, "IsDeleted", DbType.Boolean, house.IsDeleted); db.AddInParameter(command, "IsPartialHouse", DbType.Boolean, house.IsPartialHouse); db.AddInParameter(command, "CreatedBy", DbType.Guid, house.CreatedBy); db.AddInParameter(command, "RatingValue", DbType.Decimal, house.RatingValue); db.AddInParameter(command, "Price", DbType.Decimal, house.Price); db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30); if (transaction == null) { db.ExecuteNonQuery(command); } else { db.ExecuteNonQuery(command, transaction); } house.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString()); house.UpdatedDate = house.CreatedDate; return true; }
public bool IsHouseExist(House house) { Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_House_IsHouseExist"); db.AddInParameter(command, "HouseId", DbType.Guid, house.HouseId); db.AddOutParameter(command, "IsExist", DbType.Boolean, 1); db.ExecuteNonQuery(command); return Convert.ToBoolean(db.GetParameterValue(command, "IsExist").ToString()); }
public bool Insert(House house) { Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); return this.Insert(house, db, null); }
public House SelectByRoomId(Guid BaseHouseRoomId) { House entity = new House(); Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_HouseSelectByBaseHouseRoomId"); db.AddInParameter(dbCommand, "BaseHouseRoomId", DbType.Guid, BaseHouseRoomId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { if (entity == null) { entity = new House(); } RHP.Utility.Generic.AssignDataReaderToEntity(dataReader, entity); } } return entity; }
public bool SaveHouseInfo() { bool result = true; House house = new House(); if (hdHouseId.Value != string.Empty || hdHouseId.Value != null) { //if (chknotavailable.Checked == true) //{ house.HouseId = Guid.Parse(hdHouseId.Value); house.LandlordId = Guid.Parse(hdLandloadId.Value); house.StreetAddress = RentalAddress.Text.Trim(); house.City = RentalCity.Text.Trim(); house.StateId = Int32.Parse(Drpstate.SelectedValue.Trim()); house.Zip = RentalZip.Text.Trim(); house.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); house.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); house.IsPartialHouse = true; User user_ = new User(); user_.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); user_.HouseId = Guid.Parse(hdHouseId.Value); user_.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); user_.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); if (result = house.Save()) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile_Update_Current_House.aspx';}", true); // Save_Student_House(user_); } // } } else { if (DrpHouse.SelectedItem.Value.ToString() != "-1") { User user_ = new User(); user_.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); user_.HouseId = Guid.Parse(hdHouseId.Value); user_.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); user_.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile_Update_Current_House.aspx';}", true); // Save_Student_House(user_); } } return result; }
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; }
private void FillOptions() { // HouseId = Guid.Parse(Session[Constants.SESSION_HOUSEID].ToString()); house = House.Select(HouseId); if (house.HouseOptionList != null && house.HouseOptionList.Count > 0) { List<HouseOption> houseOptions = house.HouseOptionList.Where<HouseOption>(v => v.Option.OptionCategoryId == (int)Enums.OptionCategory.Basic_Features).ToList(); if (houseOptions.Count() > 0) { CheckBasicFeatureList(houseOptions); } houseOptions.Clear(); houseOptions = house.HouseOptionList.Where<HouseOption>(v => v.Option.OptionCategoryId == (int)Enums.OptionCategory.Furnished_Kitchen).ToList(); if (houseOptions.Count() > 0) { CheckFurnishedKitchenList(houseOptions); } houseOptions.Clear(); houseOptions = house.HouseOptionList.Where<HouseOption>(v => v.Option.OptionCategoryId == (int)Enums.OptionCategory.Furnished_Living_Space).ToList(); if (houseOptions.Count() > 0) { CheckFurnishedLivingSpaceList(houseOptions); } houseOptions.Clear(); houseOptions = house.HouseOptionList.Where<HouseOption>(v => v.Option.OptionCategoryId == (int)Enums.OptionCategory.Furnished_Rooms).ToList(); if (houseOptions.Count() > 0) { CheckFurnishedRoomsList(houseOptions); } } }
public bool Update(House house) { Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); return(this.Update(house, db, null)); }
public static House Select(Guid houseId) { House house = new House(); house.HouseId = houseId; if (!new HouseDAO().Select(house)) { house = null; } return house; }
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)) { } }
/// <summary> /// Last step of the wizzard /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LBSaveRoomNumber_Click(object sender, EventArgs e) { Step1.Visible = false; DromDetails.Visible = false; Step2.Visible = false; Step3.Visible = false; ///1. Check if a land lord has been created for this Base house id, if not create a landlord. Done. ///1.1. If there is no landlord created, then we need to create a new user in the user table as well. Done ///2. Check if the room is added to the house table as a new house, if not added, add a new record. ///3. Insert update the roomid of this student in user table ///4. Send the email to the landlord email address. Not done in this release. //1. int baseHouseId; Guid baseHouseLandlordId = Guid.Empty; if (int.TryParse(HiddenFieldBaseHouseId.Value, out baseHouseId)) { baseHouseLandlordId = SaveLandload(baseHouseId); } Guid roomNumber; BaseHouseRoom newBaseHouseRoom; Guid houseId; if (Guid.TryParse(HiddenFieldBaseHouseRoomId.Value.Trim(), out roomNumber)) { newBaseHouseRoom = BaseHouseRoom.Select(roomNumber); if (House.SelectByRoomId(roomNumber) == null) { //Insert Room to house table House newHouse = new House(); newHouse.LandlordId = new Guid(); newHouse.StreetAddress = Address.Text; newHouse.City = City.Text; newHouse.StateId = 0; newHouse.BaseHouseRoomId = roomNumber; newHouse.Zip = ZipCode.Text; newHouse.YearHomeBuild = 0; newHouse.BedRooms = 0; newHouse.BathRooms = 0; newHouse.LotSquareFootage = 0; newHouse.TotalSquareFootage = 0; newHouse.UtilitiesIncludedInRent = string.Empty; newHouse.PropertyImagePath = string.Empty; newHouse.IsDeleted = false; newHouse.IsPartialHouse = false; newHouse.CreatedBy = new Guid(); newHouse.RatingValue = 0; newHouse.Price = 0; newHouse.Save(); newHouse.IsPartialHouse = false; newHouse.StreetAddress = CurrentHouse.Address; newHouse.City = CurrentHouse.City; newHouse.Zip = CurrentHouse.Zip; newHouse.CreatedBy = (Guid)Membership.GetUser().ProviderUserKey; newHouse.UpdatedBy = (Guid)Membership.GetUser().ProviderUserKey; newHouse.LandlordId = baseHouseLandlordId; newHouse.Save(); } } //Update user with roomid User loggedUser = User.Select((Guid)Membership.GetUser().ProviderUserKey); loggedUser.UpdatedBy = (Guid)Membership.GetUser().ProviderUserKey; loggedUser.BaseHouseRoomId = roomNumber; if (loggedUser.Save()) { if (IsFromWizard) { WizzardSuccess(true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile_Current_House_Details.aspx';}", true); } } }