예제 #1
0
 public async Task <BuildingDto> PurchaseBuilding(string typeBuilding)
 {
     if (await restrictionsService.IsGoldForPurchaseBuilding(kingdom.Id, typeBuilding) && !string.IsNullOrEmpty(typeBuilding))
     {
         return(await buildingService.CreateBuilding(typeBuilding));
     }
     return(null);
 }
예제 #2
0
        public async Task <IActionResult> CreateBuilding(CreateBuildingDTO input)
        {
            try
            {
                await _buildingService.CreateBuilding(input);

                return(Ok());
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #3
0
        public async Task <string> Create(BuildingInput model)
        {
            if (await _buildingService.CheckIfThisBuildingIsUnique(model.Street, model.HouseNumber, model.Place))
            {
                return(JsonConvert.SerializeObject(new { success = false }));
            }

            else
            {
                // Upload image file into uploads folder
                string filePath       = null;
                string uniqueFileName = null;
                if (model.customFile != null)
                {
                    uniqueFileName = GetUniqueFileName(model.customFile.FileName);
                    var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
                    filePath = Path.Combine(uploads, uniqueFileName);
                    model.customFile.CopyTo(new FileStream(filePath, FileMode.Create));
                }

                var building = new Building()
                {
                    BuildingName   = model.BuildingName,
                    Street         = model.Street,
                    HouseNumber    = model.HouseNumber,
                    ZipCode        = model.ZipCode,
                    Place          = model.Place,
                    Photo          = uniqueFileName,
                    BuildingTypeId = model.BuildingTypeId
                };

                await _buildingService.CreateBuilding(building, User.Identity.Name);

                return(JsonConvert.SerializeObject(new { success = true }));
            }
        }
예제 #4
0
 public ActionResult <BookDto> CreateBuilding([FromBody] BuildingDto dto)
 {
     return(Ok(_buildingService.CreateBuilding(dto.Name, dto.DisplayName, dto.Address)));
 }