示例#1
0
        public JsonResult AddUpdateData(Fixture_VM Model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    GetUserInfo(Model);

                    if (Model.FixtureID == 0 || Model.FixtureID == null)
                    {
                        var data = _FixtureRepo.Add(Model);
                        return(GetAddEditDeleteResponse(data, "Add"));
                    }
                    else if (Model.FixtureID > 0)
                    {
                        var data = _FixtureRepo.Update(Model);
                        return(GetAddEditDeleteResponse(data, "Update"));
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("FixtureController_AddUpdateData Error: ", ex);
                    return(GetAddEditErrorException(ex));
                }
            }
            return(GetModelStateIsValidException(ViewData));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,FixtureDateTime,Home,HomeScore,Away,AwayScore,Result,Group")] Fixture fixture)
        {
            if (ModelState.IsValid)
            {
                _fixtureRepository.Add(fixture);
                await _fixtureRepository.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction("Index", "Admin"));
        }