Exemplo n.º 1
0
        public virtual async Task <ActionResult> Create(RefereeModel viewModel)
        {
            ViewBag.SportType = SPList();
            ViewBag.Country   = CList();
            if (ModelState.IsValid)
            {
                if (!_Referee.IsExist(viewModel.name))
                {
                    var item = new RefereeModel
                    {
                        Country     = viewModel.Country,
                        CountryID   = viewModel.CountryID,
                        name        = viewModel.name,
                        SportType   = viewModel.SportType,
                        SportTypeID = viewModel.SportTypeID
                    };
                    _Referee.Add(item);
                    await _uow.SaveChangesAsync();

                    return(View());
                }
                else
                {
                    ViewBag.Message = "عنوان وارد شده تکراری است.";
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }