Exemple #1
0
        public List <Model.HouseModel> queryHouse(String user_id)
        {
            List <Model.HouseModel> list = new List <Model.HouseModel>();

            try
            {
                string           sql    = "select house_id,city_id,address,limitation,info,state from house where user_id = '" + user_id + "'";
                MySqlCommand     cmd    = new MySqlCommand(sql, sqlCon);
                MySqlDataReader  reader = cmd.ExecuteReader();
                Model.HouseModel hm     = null;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        hm            = new HouseModel();
                        hm.house_id   = reader[0].ToString();
                        hm.city_id    = reader[1].ToString();
                        hm.address    = reader[2].ToString();
                        hm.limitation = reader[3].ToString();
                        hm.info       = reader[4].ToString();
                        hm.state      = reader[5].ToString().ElementAt(0);
                        hm.user_id    = user_id;
                        list.Add(hm);
                    }
                }
                reader.Close();
                cmd.Dispose();
            }
            catch (Exception e)
            {
            }
            return(list);
        }
Exemple #2
0
        public IHttpActionResult GetHouseInfoById(int houseId)
        {
            var rooms       = _roomService.GetRoomsByHouseId(houseId).ToList();
            var accessories = _accessoryService.GetAccessoriesByHouseId(houseId).ToList();

            var result = new HouseModel {
                id = houseId, rooms = new List <RoomModel>()
            };


            foreach (var room in rooms)
            {
                var roomModel            = new RoomModel();
                var belongingAccessories = accessories.Where(u => u.RoomId == room.Id).ToList();

                roomModel.accessories = new List <AccessoryModel>();

                foreach (var accessory in belongingAccessories)
                {
                    var accessoryModel = new AccessoryModel
                    {
                        name   = accessory.Name,
                        pin    = accessory.Pin,
                        status = accessory.Status
                    };


                    roomModel.accessories.Add(accessoryModel);
                }

                result.rooms.Add(roomModel);
            }

            return(Ok(result));
        }
Exemple #3
0
        /// <summary>
        /// Load a house from its definition
        /// </summary>
        /// <param name="house"></param>
        public void LoadHouse(HouseData house)
        {
            RenderState.Size = house.Size;

            /**
             * Camera should be at the edge of the screen looking onto the
             * center point of the lot at a 30 degree angle
             */
            /** Size is how many tiles, the last tile has a size too so the actual vertex position is +1) **/
            var worldEdge = house.Size + 1.0f;
            var radius    = RenderState.TileToWorld((worldEdge / 2.0f));
            var opposite  = (float)Math.Cos(MathHelper.ToRadians(30.0f)) * radius;

            Camera.Position = new Vector3(radius * 2, opposite, radius * 2);
            Camera.Target   = new Vector3(radius, 0.0f, radius);
            //Camera.Translation = new Vector3(-radius, 0.0f, -radius);
            Camera.Zoom = 178;

            /**
             * Setup the 2D space
             */
            Model = new HouseModel();
            Model.LoadHouse(house);

            Scene2D.LoadHouse(Model);
            Scene3D.LoadHouse(Model);

            //Center point of the center most tile
            ViewCenter = new Vector2((RenderState.Size / 2.0f) + 30, (RenderState.Size / 2.0f) + 30);
        }
Exemple #4
0
        public async Task <ActionResult <HouseModel> > PostHouseModel(HouseModel houseModel)
        {
            _context.HouseModels.Add(houseModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHouseModel", new { id = houseModel.HouseModelID }, houseModel));
        }
        /// <summary>
        /// Generates a house with a random number of rooms.
        /// </summary>
        /// <param name="name">The name of the house.</param>
        /// <returns>Generated <see cref="HouseModel"/>.</returns>
        public static HouseModel GenerateHouse(string name)
        {
            var house = new HouseModel(name);

            house.Rooms.AddRange(GenerateRooms());
            return(house);
        }
        // GET: House/Details/{id}
        public async Task <ActionResult> Details(int id)
        {
            HouseModel detailedHouse = new HouseModel();

            // Vérification que l'ID passé soit valide
            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:62313");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync("api/houses/" + id);

                if (response.IsSuccessStatusCode)
                {
                    string temp = await response.Content.ReadAsStringAsync();

                    detailedHouse = JsonConvert.DeserializeObject <HouseModel>(temp);
                }
                else
                {
                    return(HttpNotFound());
                }
            }

            return(View(detailedHouse));
        }
        public void WardrobeCommand(Client player)
        {
            int houseId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_HOUSE_ENTERED);

            if (houseId > 0)
            {
                HouseModel house = GetHouseById(houseId);
                if (HasPlayerHouseKeys(player, house) == true)
                {
                    int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID);

                    if (Globals.GetPlayerClothes(playerId).Count > 0)
                    {
                        NAPI.ClientEvent.TriggerClientEvent(player, "showPlayerWardrobe");
                    }
                    else
                    {
                        NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NO_CLOTHES_IN_WARDROBE);
                    }
                }
                else
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_HOUSE_OWNER);
                }
            }
            else
            {
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_IN_HOUSE);
            }
        }
        public HouseModel GetHouseFavouriteById(int houseId, int userId)
        {
            HouseFavourite getFavouriteHouse = TipezeNyumbaUnitOfWork.Repository <HouseFavourite>().Get(u => u.houseID == houseId && u.userID == userId && u.status == _fieldStateManagement.GetActivatedState().fieldStateID);

            if (getFavouriteHouse == null)
            {
                return(null);
            }
            string     paymentModeInWords = getFavouriteHouse.House.PaymentMode.number + " " + getFavouriteHouse.House.PaymentMode.DurationType.type;
            HouseModel houseToDisplay     = new HouseModel()
            {
                houseID = getFavouriteHouse.houseID,
                districtHouseIsLocated = getFavouriteHouse.House.District.name,
                bedrooms                 = getFavouriteHouse.House.bedrooms,
                masterBedroomEnsuite     = getFavouriteHouse.House.masterBedroomEnsuite,
                selfContained            = getFavouriteHouse.House.selfContained,
                numberOfGarages          = getFavouriteHouse.House.numberOfGarages,
                fenceType                = getFavouriteHouse.House.FenceType1.typeOfFence,
                dateHouseWillBeAvailable = getFavouriteHouse.House.dateHouseWillBeAvailable.ToLongDateString(),
                price         = getFavouriteHouse.House.price,
                modeOfPayment = paymentModeInWords,
                dateUploaded  = getFavouriteHouse.House.dateUploaded.ToLongDateString(),
                description   = getFavouriteHouse.House.description,
                houseState    = getFavouriteHouse.House.HouseState.HouseStatus
            };

            return(houseToDisplay);
        }
Exemple #9
0
        public async Task <IActionResult> PutHouseModel(int id, HouseModel houseModel)
        {
            if (id != houseModel.HouseModelID)
            {
                return(BadRequest());
            }

            _context.Entry(houseModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HouseModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #10
0
        public ActionResult House(long id)
        {
            /*
             * HouseModel model = new HouseModel();
             * model.House = houseService.GetById(id);
             * model.HousePics = houseService.GetPics(id);
             * model.Attachments = attachmentService.GetAttachments(id);
             * return View(model);*/
            string     cacheKey = "House_" + id;
            HouseModel model    = MemcachedMgr.Instance.GetValue <HouseModel>(cacheKey);

            if (model == null)
            {
                var house = houseService.GetById(id);
                if (house == null)
                {
                    return(View("Error", (object)"不存在的房源id"));
                }
                model             = new HouseModel();
                model.House       = house;
                model.HousePics   = houseService.GetPics(id);
                model.Attachments = attachmentService.GetAttachments(id);
                MemcachedMgr.Instance.SetValue(cacheKey, model, TimeSpan.FromMinutes(1));
            }
            return(View(model));
        }
Exemple #11
0
        public static void UpdateHouse(HouseModel house)
        {
            using (var connection = Database.GetConnection()) {
                try {
                    connection.Open();
                    var command = connection.CreateCommand();

                    command.CommandText =
                        "UPDATE houses SET ipl = @ipl, posX = @posX, posY = @posY, posZ = @posZ, dimension = @dimension, name = @name, price = @price, ";
                    command.CommandText +=
                        "owner = @owner, status = @status, tenants = @tenants, rental = @rental, locked = @locked WHERE id = @id LIMIT 1";
                    command.Parameters.AddWithValue("@ipl", house.ipl);
                    command.Parameters.AddWithValue("@posX", house.position.X);
                    command.Parameters.AddWithValue("@posY", house.position.Y);
                    command.Parameters.AddWithValue("@posZ", house.position.Z);
                    command.Parameters.AddWithValue("@dimension", house.dimension);
                    command.Parameters.AddWithValue("@name", house.name);
                    command.Parameters.AddWithValue("@price", house.price);
                    command.Parameters.AddWithValue("@owner", house.owner);
                    command.Parameters.AddWithValue("@status", house.status);
                    command.Parameters.AddWithValue("@tenants", house.tenants);
                    command.Parameters.AddWithValue("@rental", house.rental);
                    command.Parameters.AddWithValue("@locked", house.locked);
                    command.Parameters.AddWithValue("@id", house.id);

                    command.ExecuteNonQuery();
                }
                catch (Exception ex) {
                    NAPI.Util.ConsoleOutput("[EXCEPTION UpdateHouse] " + ex.Message);
                    NAPI.Util.ConsoleOutput("[EXCEPTION UpdateHouse] " + ex.StackTrace);
                }
            }
        }
Exemple #12
0
        public void ArmarioCommand(Client player)
        {
            int houseId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_HOUSE_ENTERED);

            if (houseId > 0)
            {
                HouseModel house = GetHouseById(houseId);
                if (HasPlayerHouseKeys(player, house) == true)
                {
                    int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID);
                    List <ClothesModel> clothesList  = Globals.GetPlayerClothes(playerId);
                    List <String>       clothesNames = Globals.GetClothesNames(clothesList);
                    if (clothesList.Count > 0)
                    {
                        NAPI.ClientEvent.TriggerClientEvent(player, "showPlayerWardrobe", NAPI.Util.ToJson(clothesList), NAPI.Util.ToJson(clothesNames));
                    }
                    else
                    {
                        NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_NO_CLOTHES_IN_WARDROBE);
                    }
                }
                else
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_HOUSE_OWNER);
                }
            }
            else
            {
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_IN_HOUSE);
            }
        }
 public static void BuyHouse(Client player, HouseModel house)
 {
     if (house.status == Constants.HOUSE_STATE_BUYABLE)
     {
         if (NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_BANK) >= house.price)
         {
             int    bank      = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_BANK) - house.price;
             String message   = String.Format(Messages.INF_HOUSE_BUY, house.name, house.price);
             String labelText = GetHouseLabelText(house);
             NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + message);
             NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_BANK, bank);
             house.status = Constants.HOUSE_STATE_NONE;
             NAPI.TextLabel.SetTextLabelText(house.houseLabel, GetHouseLabelText(house));
             house.owner  = player.Name;
             house.locked = true;
             Database.UpdateHouse(house);
         }
         else
         {
             NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_HOUSE_NOT_MONEY);
         }
     }
     else
     {
         NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_HOUSE_NOT_BUYABLE);
     }
 }
Exemple #14
0
        public static void BuyHouse(Client player, HouseModel house)
        {
            if (house.status != Constants.HOUSE_STATE_BUYABLE)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.house_not_buyable);
                return;
            }

            if (player.GetSharedData(EntityData.PLAYER_BANK) < house.price)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.house_not_money);
                return;
            }

            int    bank      = player.GetSharedData(EntityData.PLAYER_BANK) - house.price;
            string message   = string.Format(InfoRes.house_buy, house.name, house.price);
            string labelText = GetHouseLabelText(house);

            player.SendChatMessage(Constants.COLOR_INFO + message);
            player.SetSharedData(EntityData.PLAYER_BANK, bank);
            house.status          = Constants.HOUSE_STATE_NONE;
            house.houseLabel.Text = GetHouseLabelText(house);
            house.owner           = player.Name;
            house.locked          = true;

            Task.Factory.StartNew(() =>
            {
                // Update the house
                Database.UpdateHouse(house);
            });
        }
Exemple #15
0
        public static void BuyHouse(Client player, HouseModel house)
        {
            if (house.status == Constants.HOUSE_STATE_BUYABLE)
            {
                if (player.GetSharedData(EntityData.PLAYER_BANK) >= house.price)
                {
                    int    bank      = player.GetSharedData(EntityData.PLAYER_BANK) - house.price;
                    string message   = string.Format(Messages.INF_HOUSE_BUY, house.name, house.price);
                    string labelText = GetHouseLabelText(house);
                    player.SendChatMessage(Constants.COLOR_INFO + message);
                    player.SetSharedData(EntityData.PLAYER_BANK, bank);
                    house.status          = Constants.HOUSE_STATE_NONE;
                    house.houseLabel.Text = GetHouseLabelText(house);
                    house.owner           = player.Name;
                    house.locked          = true;

                    Task.Factory.StartNew(() =>
                    {
                        // Update the house
                        Database.UpdateHouse(house);
                    });
                }
                else
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_HOUSE_NOT_MONEY);
                }
            }
            else
            {
                player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_HOUSE_NOT_BUYABLE);
            }
        }
Exemple #16
0
        public void CMD_hdl(Player client, int houseid)
        {
            if (!HouseList.Exists(x => x.HouseID == houseid))
            {
                client.SendChatMessage("Дом с таким ID не найден!");
                return;
            }
            House h = HouseList.Where(x => x.HouseID == houseid).First();

            h.HouseColShape.Delete();
            h.HouseMarker.Delete();
            h.HouseBlip.Delete();
            h.HouseText.Delete();

            HouseList.Remove(h);

            // new MySqlConnector().RequestExecuteNonQuery($"DELETE FROM house WHERE h_id = {houseid}");
            using (DataBase.AppContext db = new DataBase.AppContext())
            {
                HouseModel md = new HouseModel()
                {
                    Id = houseid
                };
                db.House.Attach(md);
                db.House.Remove(md);
                db.SaveChanges();
            }

            client.SendChatMessage($"Дом {houseid} успешно был удален!");
        }
        public static void RetrievePropertiesDataEvent(Client player, int targetId)
        {
            // Initialize the variables
            List <string> houseAddresses = new List <string>();
            string        rentedHouse    = string.Empty;

            // Get the target player
            Client target = NAPI.Pools.GetAllPlayers().Find(p => p.Value == targetId);

            // Get the houses where the player is the owner
            List <HouseModel> houseList = House.houseList.Where(h => h.owner == target.Name).ToList();

            foreach (HouseModel house in houseList)
            {
                // Add the name of the house to the list
                houseAddresses.Add(house.name);
            }

            if (target.GetData(EntityData.PLAYER_RENT_HOUSE) > 0)
            {
                // Get the name of the rented house
                int        houseId          = target.GetData(EntityData.PLAYER_RENT_HOUSE);
                HouseModel rentedHouseModel = House.houseList.Where(h => h.id == houseId).FirstOrDefault();
                rentedHouse = rentedHouseModel == null ? string.Empty : rentedHouseModel.name;
            }

            // Show the data for the player
            player.TriggerEvent("showPropertiesData", NAPI.Util.ToJson(houseAddresses), rentedHouse);
        }
        public ActionResult MoreInfo(int id)
        {
            HouseModel Apar = _context.Houses.FirstOrDefault(t => t.Id == id);


            return(View(Apar));
        }
        public ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize("ManageHouse"))
            {
                return(AccessDeniedView());
            }

            if (id == 0)
            {
                throw new ArgumentNullException("id");
            }

            var model    = new HouseModel();
            var objHouse = _smsService.GetHouseById(id);

            if (objHouse != null)
            {
                model = objHouse.ToModel();
            }

            model.AvailableAcadmicYears = _smsService.GetAllAcadmicYears().Select(x => new SelectListItem()
            {
                Text     = x.Name.Trim(),
                Value    = x.Id.ToString(),
                Selected = model.AcadmicYearId == x.Id
            }).ToList();
            return(View(model));
        }
Exemple #20
0
        public void UnrentCommand(Client player)
        {
            int rentedHouse = player.GetData(EntityData.PLAYER_RENT_HOUSE);

            // Check if the house has any rented house
            if (rentedHouse == 0)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_rented_house);
                return;
            }

            // Get the house where the player is rented
            HouseModel house = GetHouseById(rentedHouse);

            if (player.Position.DistanceTo2D(house.position) > 2.5f)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_in_house_door);
                return;
            }

            // Remove player's rental
            player.SetData(EntityData.PLAYER_RENT_HOUSE, 0);
            house.tenants++;

            Task.Factory.StartNew(() =>
            {
                // Update house's tenants
                Database.UpdateHouse(house);
            });

            // Send the message to the player
            string message = string.Format(InfoRes.house_rent_stop, house.name);

            player.SendChatMessage(Constants.COLOR_INFO + message);
        }
        public async Task UpdateShouldAlterPropertiesOfEntity()
        {
            var name                = "hahaha";
            var houseId             = "hehehe";
            var school              = "hihihi";
            var role                = "hohoho";
            var patronus            = "huhuhu";
            var newCharacterInfoDTO = new CharacterDTO
            {
                Name     = name,
                House    = houseId,
                School   = school,
                Role     = role,
                Patronus = patronus
            };
            var houseModel = new HouseModel
            {
                Id = houseId
            };
            var characterEntityMock = new Mock <Character>();

            var apiResult = Result <HouseModel> .Success(houseModel);

            var makeMagicApiClientMock = Mock.Of <MakeMagicApiClient>(mmac => mmac.GetHouse(houseId) == Task.FromResult(apiResult));
            var characterRepository    = Mock.Of <CharactersRepository>(cr => cr.Update(characterEntityMock.Object) == Task.FromResult(true));

            var characterEditor = new CharacterEditor(makeMagicApiClientMock, characterRepository);
            var result          = await characterEditor.Update(characterEntityMock.Object, newCharacterInfoDTO);

            Assert.False(result.Error);
            Assert.Equal(characterEntityMock.Object, result.Value);
            characterEntityMock.Verify(c => c.Update(newCharacterInfoDTO.Name, newCharacterInfoDTO.Role, newCharacterInfoDTO.School, newCharacterInfoDTO.House, newCharacterInfoDTO.Patronus),
                                       Times.Once());
        }
Exemple #22
0
        public void WardrobeCommand(Client player)
        {
            int houseId = player.GetData(EntityData.PLAYER_HOUSE_ENTERED);

            if (houseId > 0)
            {
                HouseModel house = GetHouseById(houseId);
                if (HasPlayerHouseKeys(player, house) == true)
                {
                    int playerId = player.GetData(EntityData.PLAYER_SQL_ID);

                    if (Globals.GetPlayerClothes(playerId).Count > 0)
                    {
                        player.TriggerEvent("showPlayerWardrobe");
                    }
                    else
                    {
                        player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.no_clothes_in_wardrobe);
                    }
                }
                else
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_house_owner);
                }
            }
            else
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_in_house);
            }
        }
        public async Task CreationShouldReturnEntityInsertedWithId()
        {
            var idAssigned   = 1;
            var name         = "hahaha";
            var houseId      = "hehehe";
            var school       = "hihihi";
            var role         = "hohoho";
            var patronus     = "huhuhu";
            var characterDTO = new CharacterDTO
            {
                Name     = name,
                House    = houseId,
                School   = school,
                Role     = role,
                Patronus = patronus
            };
            var houseModel = new HouseModel
            {
                Id = houseId
            };
            var characterEntityMock = Mock.Of <Character>(c => c.Id == idAssigned && c.Name == name && c.House == houseId && c.School == school && c.Role == role && c.Patronus == patronus);

            var apiResult = Result <HouseModel> .Success(houseModel);

            var makeMagicApiClientMock = Mock.Of <MakeMagicApiClient>(mmac => mmac.GetHouse(houseId) == Task.FromResult(apiResult));
            var characterRepository    = Mock.Of <CharactersRepository>(cr =>
                                                                        cr.Insert(It.Is <Character>(c => c.Name == name && c.House == houseId && c.School == school && c.Role == role && c.Patronus == patronus)) == Task.FromResult(idAssigned) &&
                                                                        cr.Get(idAssigned) == Task.FromResult(characterEntityMock));

            var characterEditor = new CharacterEditor(makeMagicApiClientMock, characterRepository);
            var result          = await characterEditor.Create(characterDTO);

            Assert.False(result.Error);
            Assert.Equal(characterEntityMock, result.Value);
        }
Exemple #24
0
        public static int AddHouse(HouseModel house)
        {
            var houseId = 0;

            using (var connection = Database.GetConnection()) {
                try {
                    connection.Open();
                    var command = connection.CreateCommand();

                    command.CommandText =
                        "INSERT INTO houses (ipl, posX, posY, posZ, dimension) VALUES (@ipl, @posX, @posY, @posZ, @dimension)";
                    command.Parameters.AddWithValue("@ipl", house.ipl);
                    command.Parameters.AddWithValue("@posX", house.position.X);
                    command.Parameters.AddWithValue("@posY", house.position.Y);
                    command.Parameters.AddWithValue("@posZ", house.position.Z);
                    command.Parameters.AddWithValue("@dimension", house.dimension);

                    command.ExecuteNonQuery();
                    houseId = (int)command.LastInsertedId;
                }
                catch (Exception ex) {
                    NAPI.Util.ConsoleOutput("[EXCEPTION AddHouse] " + ex.Message);
                    NAPI.Util.ConsoleOutput("[EXCEPTION AddHouse] " + ex.StackTrace);
                }
            }

            return(houseId);
        }
Exemple #25
0
 public ActionResult EditProperty(int id, PropertyTypeClassifier type)
 {
     PropertyViewOperation p = new PropertyViewOperation();
     if (type == PropertyTypeClassifier.Apartament)
     {
         ApartmentModel model = p.GetPropertyApartment(id);
         return View("~/Views/Property/Submit.cshtml", model);
     }
     else if (type == PropertyTypeClassifier.House)
     {
         HouseModel model = p.GetPropertyHouse(id);
         return View("~/Views/Property/Submit.cshtml", model);
     }
     else if (type == PropertyTypeClassifier.Commercial)
     {
       CommercialModel model =  p.GetPropertyCommercial(id);
         return View("~/Views/Property/Submit.cshtml", model);
     }
     else
     {
        LandModel model= p.GetPropertyLand(id);
         return View("~/Views/Property/Submit.cshtml", model);
     }
     
 }
Exemple #26
0
 public IActionResult LeaveHouse(HouseModel house)
 {
     houseService.LeaveHouseAsync(new House {
         Id = house.Id
     }, AccountModel.GetInstace().Session).Wait();
     return(Home());
 }
Exemple #27
0
        public async Task <HouseModel> CreateHouse(HouseModel model)
        {
            using (IDbConnection connection = new MySqlConnection(_connectionString))
            {
                connection.Open();
                var p = new DynamicParameters();
                p.Add("@_Id", model.Id);
                p.Add("@_Address", model.Address);
                p.Add("@_City", model.City);
                p.Add("@_State", model.State);
                p.Add("@_PostCode", model.PostCode);
                p.Add("@_OwnerId", model.OwnerId);
                p.Add("@_CurrentRental", model.CurrentRental);
                p.Add("@_ManagementFee", model.ManagementFee);
                p.Add("@_IsRentedOut", model.IsRentedOut);
                p.Add("@_Notes", model.Notes);
                p.Add("@_HouseId", dbType: DbType.Int32, direction: ParameterDirection.Output);
                await connection.ExecuteAsync("sp_create_house", p, commandType : CommandType.StoredProcedure);

                model.Id = p.Get <int>("@_HouseId");
                if (model.Id < 0)
                {
                    return(null);
                }
            }

            return(model);
        }
Exemple #28
0
        public void RentableCommand(Client player, int amount = 0)
        {
            if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_HOUSE_ENTERED) == 0)
            {
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_IN_HOUSE);
            }
            else
            {
                int        houseId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_HOUSE_ENTERED);
                HouseModel house   = GetHouseById(houseId);
                if (house == null || house.owner != player.Name)
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_HOUSE_OWNER);
                }
                else if (amount > 0)
                {
                    house.rental  = amount;
                    house.status  = Constants.HOUSE_STATE_RENTABLE;
                    house.tenants = 2;

                    // Update house's textlabel
                    String labelText = GetHouseLabelText(house);
                    NAPI.TextLabel.SetTextLabelText(house.houseLabel, labelText);

                    Task.Factory.StartNew(() =>
                    {
                        // Update the house
                        Database.UpdateHouse(house);
                    });

                    // Message sent to the player
                    String message = String.Format(Messages.INF_HOUSE_STATE_RENT, amount);
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + message);
                }
                else if (house.status == Constants.HOUSE_STATE_RENTABLE)
                {
                    house.status  = Constants.HOUSE_STATE_NONE;
                    house.tenants = 2;

                    // Update house's textlabel
                    String labelText = GetHouseLabelText(house);
                    NAPI.TextLabel.SetTextLabelText(house.houseLabel, labelText);

                    Task.Factory.StartNew(() =>
                    {
                        // Update the house
                        Database.KickTenantsOut(house.id);
                        Database.UpdateHouse(house);
                    });

                    // Message sent to the player
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_HOUSE_RENT_CANCEL);
                }
                else
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PRICE_POSITIVE);
                }
            }
        }
Exemple #29
0
 public void DeleteHouse(HouseModel house)
 {
     if (house == null)
     {
         throw new ArgumentNullException();
     }
     _context.Remove(house);
 }
        /// <summary>
        /// Generates a house with a random number of rooms.
        /// </summary>
        /// <param name="name">The name of the house.</param>
        /// <returns>Generated <see cref="HouseModel"/>.</returns>
        public static HouseModel GenerateHouse(string name)
        {
            var price = (decimal) (_priceGenerator.NextDouble() * 42.42d);

            var house = new HouseModel(name, price);
            house.Rooms.AddRange(GenerateRooms());
            return house;
        }
        public IActionResult GetHouseByType(string type)
        {
            // Wyszukanie samochodu po modelu
            HouseModel house = this.allHouses.Where(a => a.Type.ToLower() == type.ToLower()).FirstOrDefault();

            // Przekazanie obiektu do widoku
            return(View(house));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HouseViewModel"/> class.
        /// </summary>
        /// <param name="house">The house.</param>
        public HouseViewModel(HouseModel house)
        {
            Argument.IsNotNull("house", house);

            House = house;
        }
 /// <summary>
 /// Generates a house with a random number of rooms.
 /// </summary>
 /// <param name="name">The name of the house.</param>
 /// <returns>Generated <see cref="HouseModel"/>.</returns>
 public static HouseModel GenerateHouse(string name)
 {
     var house = new HouseModel(name);
     house.Rooms.AddRange(GenerateRooms());
     return house;
 }