Example #1
0
        public void Create(StadiumDTO stadiumDto)
        {
            if (stadiumDto.Name == null || stadiumDto.Name.Length < 1)
            {
                throw new ValidationException("Имя стадиона должно состоять минимум из одного символа", "Name");
            }
            var stadium = new Stadium {
                Name = stadiumDto.Name
            };

            Database.Stadiums.Create(stadium);
            Database.Save();
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request[Constants.QueryParam.ObjectId].Length > 0)
                {
                    int stadiumId = int.Parse(Request[Constants.QueryParam.ObjectId]);
                    DataItem = new StadiumDTOHelper().GetFromDB(stadiumId);

                    SearchParameters.Match searchParam = new SearchParameters.Match();
                    searchParam.Stadium_Id = stadiumId;
                    ml.DataBind(searchParam);
                }
            }
        }
Example #3
0
 public ActionResult Create(StadiumViewModel stadium)
 {
     try
     {
         var stadiumDTO = new StadiumDTO {
             Name = stadium.Name
         };
         stadiumService.Create(stadiumDTO);
         return(RedirectToAction("Index"));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError(ex.Property, ex.Message);
     }
     return(View(stadium));
 }
Example #4
0
        public async void GetStadiumByIdOk(int id)
        {
            // Arrange
            StadiumDTO returnedStadium = null;

            // Act
            var response = await _client.GetAsync($"api/stadiums/{id}");

            response.EnsureSuccessStatusCode();

            var responseString = await response.Content.ReadAsStringAsync();

            var deserializeErr = Record.Exception(()
                                                  => returnedStadium = JsonConvert.DeserializeObject <StadiumDTO>(responseString));

            // Assert
            Assert.Null(deserializeErr);
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.NotNull(returnedStadium);
        }