Exemplo n.º 1
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);
     }
     
 }
        public async Task <ActionResult> Edit(ApartmentModel apartment)
        {
            if (!ModelState.IsValid)
            {
                return(View(apartment));
            }

            var databaseApartment = _apartmentService.GetById(apartment.Id);

            if (databaseApartment == null)
            {
                return(StatusCode(404));
            }

            databaseApartment.AddToHistory(apartment.FirstName, apartment.LastName, apartment.NoOfPersons);
            var apartmentForDatabase = apartment.MapToDatabase();

            apartmentForDatabase.FirstName   = databaseApartment.FirstName;
            apartmentForDatabase.LastName    = databaseApartment.LastName;
            apartmentForDatabase.NoOfPersons = databaseApartment.NoOfPersons;
            await _apartmentService.UpdateAsync(apartmentForDatabase);

            var building = _buildingService.GetByOwnerAndId(User.FindFirstValue(ClaimTypes.NameIdentifier), apartment.BuildingId);

            TempData["SelectedBuilding"] = building.Id;
            return(RedirectToAction(nameof(List)));
        }
Exemplo n.º 3
0
        private ApartmentModel GetApartmentModelById(int id)
        {
            ApartmentModel apartment = null;

            try
            {
                apartment = new ApartmentModel()
                {
                    Id            = _apartmentService.GetApartmentById(id).Id,
                    Name          = _apartmentService.GetApartmentById(id).Name,
                    Price         = _apartmentService.GetApartmentById(id).Price,
                    AvailableFrom = _apartmentService.GetApartmentById(id).AvailableFrom,
                    NumberOfBeds  = _apartmentService.GetApartmentById(id).NumberOfBeds,
                    AverageRating = float.Parse(_apartmentService.GetApartmentById(id).AverageRating.ToString("0.00")),
                    Phone         = _apartmentService.GetApartmentById(id).Phone,
                    Description   = _apartmentService.GetApartmentById(id).Description
                };
                if (apartment.Description == null || apartment.Description.Length == 0)
                {
                    apartment.Description = "No description available...";
                }
            }
            catch (Exception ex)
            {
                _log.LogError(ex, ex.Message);
            }
            return(apartment);
        }
Exemplo n.º 4
0
 public void DeleteApartment(ApartmentModel house)
 {
     if (house == null)
     {
         throw new ArgumentNullException();
     }
     _context.Remove(house);
 }
Exemplo n.º 5
0
 public void CreateApartment(ApartmentModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     _context.Add(model);
 }
        public List <CalendarModel> GetMaidCalendar(int minTime, int maxTime)
        {
            IEnumerable <string> values;

            if (Request.Headers.TryGetValues("Token", out values))
            {
                var token      = values.First();
                var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token));
                var maid       = _service.GetActiveMaidById(tokenModel.Id);
                if (Equals(maid, null))
                {
                    ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found");
                }
                var x                 = 60 * 60 * 24;
                var result            = new List <CalendarModel>();
                var contractEmployees = _service.GetAllCurrentContractEmployeeByEmployeeId(maid.employee_id);
                while (minTime < maxTime)
                {
                    var max           = minTime + x;
                    var dow           = (int)ConvertDatetime.UnixTimeStampToDateTime(minTime).DayOfWeek;
                    var apartmentList = new List <ApartmentModel>();
                    foreach (var item in contractEmployees)
                    {
                        var days = item.work_date.Split(',').ToList();
                        if (days.IndexOf(dow.ToString()) != -1)
                        {
                            var apartment = new ApartmentModel
                            {
                                Id          = item.contract.apartment.apartment_id,
                                Code        = item.contract.apartment.code,
                                NoBedRoom   = item.contract.no_bedroom,
                                WorkHour    = item.work_hour,
                                Address     = item.contract.address,
                                NoApartment = item.contract.no_apartment,
                                Building    = item.contract.building,
                                Project     = !Equals(item.contract.apartment.project_id, null) ? new ProjectModel
                                {
                                    Name = item.contract.apartment.project.project_content.FirstOrDefault(p => p.language == 0).name
                                } : new ProjectModel()
                            };
                            apartmentList.Add(apartment);
                        }
                    }
                    var calendar = new CalendarModel
                    {
                        ApartmentList = apartmentList,
                        Time          = minTime
                    };
                    result.Add(calendar);
                    minTime = max;
                }

                return(result);
            }
            return(new List <CalendarModel>());
        }
Exemplo n.º 7
0
        public IActionResult Create()
        {
            var model = new ApartmentModel()
            {
                NumberOfBedsList = GetNumberOfBeds(),
                Cities           = GetAllCities(),
            };

            return(View(model));
        }
Exemplo n.º 8
0
        public ActionResult <ApartmentReadDTO> GetApartmentByID(int id)
        {
            ApartmentModel apartment = _repo.GetApartmentByID(id);

            if (apartment == null)
            {
                return(NotFound());
            }
            return(Ok(_mapper.Map <ApartmentModel>(apartment)));
        }
Exemplo n.º 9
0
 public List <apartment> GetSimilarApartment(ApartmentModel model)
 {
     return(ApartmentRepository.FindBy(p =>
                                       p.project_id == model.ProjectId && p.no_bedroom == model.NoBedRoom && p.city.Contains(model.City) && p.status == 1 && !p.is_import)
            .OrderByDescending(p => p.price)
            .Include(p => p.aparment_image).Include(p => p.apartment_content)
            .Include(p => p.apartment_facility).Include(p => p.user_profile).Include(p => p.project.project_content)
            .Skip(0).Take(3)
            .OrderByDescending(p => p.apartment_id)
            .ToList());
 }
Exemplo n.º 10
0
        public async Task AddTenant(AddUserWithApartmentModel userWithApartmentModel)
        {
            var userModel   = new AddUserModel(userWithApartmentModel);
            var addedUserId = await _userManager.AddTenant(_serviceMapper, userModel);

            var apartment = new ApartmentModel(userWithApartmentModel, addedUserId);

            _apartmentService.AddApartment(apartment);

            _mailService.NewTenantAdded(userModel);
        }
Exemplo n.º 11
0
        public virtual IActionResult GetItem([FromBody] int id)
        {
            ApartmentDto dto = service.GetById(id);

            if (dto == null)
            {
                return(BadRequest());
            }

            ApartmentModel model = mapper.Map <ApartmentModel>(dto);

            return(Ok(model));
        }
Exemplo n.º 12
0
        public IActionResult Create([FromForm] ApartmentModel model)
        {
            if (ModelState.IsValid)
            {
                var apt = _apartmentService.GetApartmentByName(model.Name);
                if (apt != null)
                {
                    model.IsDuplicateName  = true;
                    model.Cities           = GetAllCities();
                    model.NumberOfBedsList = GetNumberOfBeds();
                    return(View(model));
                }
                if (model.AvailableFrom < DateTime.Today)
                {
                    model.Cities           = GetAllCities();
                    model.NumberOfBedsList = GetNumberOfBeds();
                    model.IsLowerDate      = true;
                    return(View(model));
                }
                if (model.Phone != null)
                {
                    model.Phone = model.Phone.ToString().Replace("-", "");
                }
                var apartment = new Apartment
                {
                    Name          = model.Name,
                    Address       = model.Address,
                    Price         = model.Price.GetValueOrDefault(),
                    NumberOfBeds  = model.NumberOfBeds,
                    Description   = model.Description,
                    Phone         = model.Phone,
                    CityId        = model.CityId,
                    AvailableFrom = model.AvailableFrom.GetValueOrDefault()
                };
                try
                {
                    _apartmentService.CreateApartment(apartment);
                }
                catch (Exception ex)
                {
                    model.IsTryCatch = true;
                    _log.LogError(ex, ex.Message);
                }
                var apartmentid = _apartmentService.GetApartmentByName(apartment.Name);
                return(RedirectToAction("Index", "Details", new { id = apartmentid.Id }));
            }

            model.Cities           = GetAllCities();
            model.NumberOfBedsList = GetNumberOfBeds();
            return(View(model));
        }
Exemplo n.º 13
0
        public virtual IActionResult UpdateItem([FromBody] ApartmentModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ApartmentDto dto = mapper.Map <ApartmentDto>(model);

            service.Update(dto);

            return(Ok());
        }
Exemplo n.º 14
0
        public ActionResult SubmitApartment(ApartmentModel model, HttpPostedFileBase[] files)
        {
            if (files.Length == 1 && files[0] == null && !model.HasImage)
            {
                ModelState.AddModelError(string.Empty, "A photo file must be chosen.");
            }

            if (ModelState.IsValid)
            {
                PhotoProcessing(files, model);
                ApartmentOperation operation = new ApartmentOperation();
                var result = operation.Execute(model, User.Identity.GetUserId());

                if (result.IsSuccess)
                    return RedirectToAction("Index");
            }
           // ModelState.Clear();
            return View("Submit", model);
        }
Exemplo n.º 15
0
        public async Task <ActionResult> Add(ApartmentModel apartment)
        {
            if (!ModelState.IsValid)
            {
                return(View(apartment));
            }
            var databaseApartment = apartment.MapToDatabase();
            var building          = _buildingService.GetByOwnerAndId(User.FindFirstValue(ClaimTypes.NameIdentifier), apartment.BuildingId);

            databaseApartment.Id = Guid.NewGuid();
            databaseApartment.AddHistoryNewItems(apartment.FirstName, apartment.LastName, apartment.NoOfPersons);
            databaseApartment.Number = building.Apartments.Count + 1;
            await _apartmentService.SaveAsync(databaseApartment);

            building.Apartments.Add(databaseApartment.Id);
            await _buildingService.UpdateAsync(building);

            TempData["SelectedBuilding"] = building.Id;
            return(RedirectToAction(nameof(List)));
        }
Exemplo n.º 16
0
 public IActionResult AddApartment(ApartmentModel apartmentModel)
 {
     return(Created("", _apartmentService.AddApartment(apartmentModel)));
 }
Exemplo n.º 17
0
 public async Task UpdateApartment(ApartmentModel model)
 {
     await _apartmentRepository.UpdateAsync(_apartmentMapper.MapBack(model));
 }
Exemplo n.º 18
0
 public async Task <ApartmentModel> CreateApartment(ApartmentModel model)
 {
     return(_apartmentMapper.Map(await _apartmentRepository.AddAsync(_apartmentMapper.MapBack(model))));
 }
Exemplo n.º 19
0
 public void UpdateApartment(ApartmentModel model)
 {
     //
 }
Exemplo n.º 20
0
        public ApartmentModel GetPropertyApartment(int id)
        {
            ApartmentModel model = new ApartmentModel();

            using (PMSContext db = new PMSContext())
            {
                var dbmodel = db.Properties.FirstOrDefault(x => x.PropertyId == id);

                model.PropertyType   = (PropertyTypeClassifier)dbmodel.TypeId;
                model.PropertyStatus = (PropertyStatusClassifier)dbmodel.SellingCondition;
                model.PropertyId     = dbmodel.PropertyId;
                model.Price          = dbmodel.Price;

                //addresss
                model.PropertyDescription = dbmodel.PropertyDescription;
                var addressModel = db.PropertyAddresses.FirstOrDefault(x => x.PropertyAddressId == dbmodel.PropertyAddressId);
                model.City               = addressModel.CityId;
                model.District           = addressModel.DistrictId;
                model.Metro              = addressModel.MetroId;
                model.AddressDescription = addressModel.Description;

                //photo
                model.Photos = new List <PhotoModel>();
                foreach (var d in db.Photos.Where(x => x.PropertyId == dbmodel.PropertyId))
                {
                    model.Photos.Add(new PhotoModel {
                        PhotoPath = d.PhotoPath
                    });
                }

                //apart
                model.ApartmentType        = (ApartmentTypeClassifier)dbmodel.ApartmentType;
                model.FloorNumberApartment = (int)dbmodel.FloorNumber;
                model.FlatFloorApartment   = (int)dbmodel.FlatFloor;
                model.TotalAreaApartment   = dbmodel.TotalArea;
                model.BathroomApartment    = (int)dbmodel.Bathroom;
                model.RoomNumberApartment  = (int)dbmodel.RoomNumber;
                model.HasImage             = true;

                //feature
                var ft = db.PropertyFeatures.Where(x => x.PropertyId == dbmodel.PropertyId);

                foreach (var f in ft)
                {
                    var fea = db.Features.FirstOrDefault(x => x.FeatureId == f.FeatureId);
                    if (fea.FeatureTitle == "Credit")
                    {
                        model.CreditApartment = true;
                    }
                    if (fea.FeatureTitle == "HasDocument")
                    {
                        model.HasDocumentApartment = true;
                    }
                    if (fea.FeatureTitle == "Repairing")
                    {
                        model.RepairingApartment = true;
                    }
                    if (fea.FeatureTitle == "Gas")
                    {
                        model.GasApartment = true;
                    }
                    if (fea.FeatureTitle == "Water")
                    {
                        model.WaterApartment = true;
                    }
                    if (fea.FeatureTitle == "Electric")
                    {
                        model.ElectricApartment = true;
                    }
                    if (fea.FeatureTitle == "Telephone")
                    {
                        model.TelephoneApartment = true;
                    }
                    if (fea.FeatureTitle == "CabelTV")
                    {
                        model.CabelTVApartment = true;
                    }
                    if (fea.FeatureTitle == "Lift")
                    {
                        model.LiftApartment = true;
                    }

                    if (fea.FeatureTitle == "CentralHeatingSystem")
                    {
                        model.CentralHeatingSystemApartment = true;
                    }


                    if (fea.FeatureTitle == "Internet")
                    {
                        model.InternetApartment = true;
                    }

                    if (fea.FeatureTitle == "Conditioner")
                    {
                        model.ConditionerApartment = true;
                    }

                    if (fea.FeatureTitle == "KitchenFurniture")
                    {
                        model.KitchenFurnitureApartment = true;
                    }
                    if (fea.FeatureTitle == "Handy")
                    {
                        model.HandyApartment = true;
                    }
                    if (fea.FeatureTitle == "CombySystem")
                    {
                        model.CombySystemApartment = true;
                    }
                }
            }

            Repository rep = new Repository();

            model.DistrictList = rep.GetDistricts(model.City);
            model.MetroList    = rep.GetMetroes(model.City);

            return(model);
        }
 public IViewComponentResult Invoke(ApartmentModel apartment)
 {
     return(View(apartment));
 }