public IActionResult Edit(int id)
        {
            var building = new Building();

            if (id > 0)
            {
                building = _buildingRepository.GetBuilding(id);
                if (building == null)
                {
                    return(NotFound());
                }
            }

            return(View(new BuildingViewModel
            {
                BuildingId = building.BuildingId,
                CreatedOn = id > 0 ? building.CreatedOn : (DateTime?)null,
                CreatedBy = id > 0 ? building.CreatedByName : string.Empty,
                LastUpdatedOn = id > 0 ? building.LastUpdatedOn : (DateTime?)null,
                LastUpdatedBy = building.LastUpdatedByName,
                BuildingName = building.BuildingName,
                AddressLine1 = building.AddressLine1,
                AddressLine2 = building.AddressLine2,
                AddressLine3 = building.AddressLine3,
                City = building.City,
                State = building.State,
                ZipCode = building.ZipCode,
                PurchaseDate = id > 0 ? building.PurchaseDate : (DateTime?)null,
                PurchasePrice = building.PurchasePrice,
                SellDate = id > 0 ? building.SellDate : null,
                SellPrice = building.SellPrice,
                NumberOfUnits = building.NumberOfUnits
            }));
        }
Пример #2
0
 public async Task <IActionResult> GetBuildingById(int id)
 {
     if (await _buildingRepository.GetBuilding(id) is Domain.Models.Building buildingItem)
     {
         return(Ok(buildingItem));
     }
     return(NotFound());
 }
Пример #3
0
        public ActionResult <Building> Get(int id)
        {
            var building = _buildingRepository.GetBuilding(id);

            if (building == null)
            {
                return(NotFound());
            }

            return(Ok(building));
        }
Пример #4
0
        public async Task <IActionResult> GetBuilding(int id)
        {
            var building = await repository.GetBuilding(id);

            if (building == null)
            {
                return(NotFound());
            }

            var buildingResource = mapper.Map <Building, BuildingResource>(building);

            return(Ok(buildingResource));
        }
Пример #5
0
        public async Task <IActionResult> InsertDamage(AddDamageDTO addDamageDTO)
        {
            var user = await _userRepository.GetUserById(addDamageDTO.UserId);

            var building = await _buildingRepository.GetBuilding(addDamageDTO.BuildingId);

            var damage = new Damage()
            {
                Building       = building,
                RequestCreator = user,
                CreationDate   = DateTime.Now,
                Description    = addDamageDTO.Description,
                Status         = DamageStatus.WaitingForFix,
                Title          = addDamageDTO.Title,
            };

            var savedDamage = await _repo.AddDamage(damage);

            var messageSubject = $"Użytkownik zgłosił useterkę wymagającą naprawy";
            var messageContent = $"Zgłoszenie zostało dodane przez użytkownika: {user.FirstName} {user.LastName}.\n" +
                                 $"Status zgłoszenia zmieniono na \'Wymagający naprawy\'. W razie zastrzeżeń skontaktuj się z użytkownikiem. \n\n" +
                                 $"Treść maila wygenerowano automatycznie. Nie odpowiadaj na tego maila.";

            _mailService.SendMail(messageSubject, messageContent, "", "Home Community App");

            return(Ok(new { savedDamage.Id }));
        }
Пример #6
0
        public async Task <IActionResult> GetBuildingDataForUser(int userId)
        {
            var buildingFromRepo = await _repo.GetBuilding(userId);

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

            return(Ok(
                       new
            {
                Id = buildingFromRepo.Id,
                City = buildingFromRepo.Address.City,
                Street = buildingFromRepo.Address.Street,
                Number = buildingFromRepo.Address.Number,
            }));
        }
        public IActionResult Restore(string entity, int id)
        {
            switch (entity.ToLower().Trim())
            {
            case "building":
                var building = _buildingRepository.GetBuilding(id);
                building.IsDeleted = false;
                _buildingRepository.UpdateBuilding(building);
                break;

            case "unit":
                var unit = _unitRepository.GetUnit(id);
                unit.IsDeleted = false;
                _unitRepository.UpdateUnit(unit);
                break;
            }

            return(RedirectToAction("Index", "RecycleBin"));
        }
Пример #8
0
        public ActionResult GetBuildingDetail(int id)
        {
            var building = _buildingRepo.GetBuilding(id);

            return(AngularJsonResult(building));
        }
 public Building GetBuilding(int buildingId)
 {
     return(_buildingRepository.GetBuilding(buildingId));
 }