public ActionResult Post([FromBody] AddCondominiumRequestModel model)
 {
     try
     {
         var building = new Building()
         {
             CreatedAt     = today,
             Status        = model.Status,
             UpdatedAt     = today,
             Name          = model.Name,
             Description   = model.Description,
             NumberOfHomes = model.HomesNumber,
             CondominiumId = model.CondominiumId
         };
         _buildingService.Add(building);
         response.StatusCode = StatusCodes.Status200OK;
         response.Status     = "OK";
         response.Message    = "Edificio agregado";
         return(Ok(response));
     }
     catch (Exception e)
     {
         response.StatusCode = StatusCodes.Status400BadRequest;
         response.Status     = "BAD REQUEST";
         response.Message    = e.Message;
         return(BadRequest(response));
     }
 }
Exemple #2
0
 public IActionResult Create([Bind("BuildingID,Ref,Name,Street,Number,Zip code,City")] Building building)
 {
     if (ModelState.IsValid)
     {
         service.Add(building);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(building));
 }
Exemple #3
0
        public async Task <IActionResult> Create(BuildingDto create)
        {
            if (_buildingService.GetById(create.ID) != null)
            {
                return(BadRequest("Article ID already exists!"));
            }
            if (await _buildingService.Add(create))
            {
                return(NoContent());
            }

            throw new Exception("Creating the building failed on save");
        }
        public int Execute(CreateBuildingForm form)
        {
            var building = new Building(form.Address);

            try
            {
                building = _buildingService.Add(building);
            }
            catch (EntityAlreadyExistsException e)
            {
                throw new FormException(e.Message);
            }

            return(building.Id);
        }
        public IActionResult Add(BuildingRequest request)
        {
            Answer answer = new Answer();

            try
            {
                _buildingService.Add(request);
                answer.Successful = true;
            }
            catch (Exception err)
            {
                answer.Message = err.Message;
            }

            return(Ok(answer));
        }
 /// <summary>
 /// Adds the info for a single building.
 /// </summary>
 /// <param name="buildingInfo">The metadata associated with the building.</param>
 /// <returns></returns>
 public void PostBuilding(PostBuildingInfo buildingInfo)
 {
     VerifySecurityCode(buildingInfo.Code);
     _buildingService.Add(buildingInfo);
 }
 public ActionResult AddBuilding(Building building)
 {
     return(Json(buildingService.Add(building)));
 }