Exemplo n.º 1
0
        public async Task CreateBuildings(int countBuildings, int countEntrances)
        {
            IBuildingService buildingService = new BuildingService();

            for (int i = 0; i < countBuildings; i++)
            {
                var res = await buildingService.CreateBuilding(new BuildingModel()
                {
                    BuildingNumber = i + 1,
                });
                await CreateEntrances(res.Id, countEntrances);
            }
        }
        public async Task <ActionResult <Building> > PostBuilding(Building building)
        {
            bool postBuilding = await _buildingService.CreateBuilding(building);

            if (postBuilding == true)
            {
                return(CreatedAtAction("GetBuilding", new { id = building.Id }, building));
            }
            else
            {
                return(NotFound());
            }
        }
        public IActionResult Create(CreateBuildingModel model)
        {
            var validationResult = _service.ValidateCreateBuilding(User, model);

            if (!validationResult.Valid)
            {
                return(BadRequest(validationResult.Result));
            }
            var entity = _service.CreateBuilding(model);

            context.SaveChanges();
            return(Created($"/{ApiEndpoint.BUILDING_API}?id={entity.Id}",
                           new AppResultBuilder().Success(entity.Id)));
        }
Exemplo n.º 4
0
        private void Save()
        {
            IBuildingService buildingService = new BuildingService();
            Boolean          ret             = false;
            string           message         = String.Empty;
            Building         building        = new Building()
            {
                BuildingCode = txtBuildingCode.Text.ToString(),
                Description  = txtDescription.Text.ToString(),
                BuildingName = txtName.Text.ToString(),
                Rooms        = rooms
            };

            if (Op.Equals("edit"))
            {
                ret = buildingService.UpdateBuilding(ref building, ref message);

                building.Rooms = null;
                Log("U", "Buildings", building);
                if (rooms.Count > 0)
                {
                    foreach (Room r in rooms)
                    {
                        Log("C", "Rooms", r);
                    }
                }

                if (ret)
                {
                    MessageBox.Show("Saved Successfully");
                }
                else
                {
                    MessageBox.Show("Error Saving");
                }
                Close();
            }
            else
            {
                String la = txtBuildingCode.Text.ToString();
                if (la.Equals(String.Empty))
                {
                    MessageBox.Show("Provide Building Code");
                }
                else
                {
                    ret            = buildingService.CreateBuilding(ref building, ref message);
                    building.Rooms = null;
                    Log("C", "Buildings", building);
                    if (rooms.Count > 0)
                    {
                        foreach (Room r in rooms)
                        {
                            Log("C", "Rooms", r);
                        }
                    }
                    if (ret)
                    {
                        MessageBox.Show("Saved Successfully");
                    }
                    else
                    {
                        MessageBox.Show("Error Saving");
                    }
                    Close();
                }
            }
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Create(BuildingDTO dto)
        {
            await buildingService.CreateBuilding(dto);

            return(RedirectToAction("Index"));
        }