public IActionResult AddN([FromBody] NationalContest c)
        {
            dynamic result = new ExpandoObject();

            if (ModelState.IsValid)
            {
                NationalContest c2 = _repo.addNewNationalContest(c);

                if (c2 == null)
                {
                    result.status  = 0;
                    result.message = "Verify your infromations";
                }
                else
                {
                    result.status = 1;
                    result.result = c2;
                }
            }
            else
            {
                result.status  = 0;
                result.message = _modelServices.GetErrorMessage(ModelState);
            }


            return(Ok(result));
        }
Exemple #2
0
        public NationalContest addNewNationalContest(NationalContest c)
        {
            InternationalContest ic = getInternationalContestByEdition(c.Edition);

            if (ic != null && getNationalContest(c.NameC, c.Edition) == null && _countryRepo.isExsist(c.CountryName))
            {
                c.InternationalContest = ic;
                this._context.NationalContests.Add(c);
                this._context.SaveChanges();
                return(c);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public LocalContest addnewLocalContest(LocalContest c)
        {
            NationalContest nc = null;

            if (c != null)
            {
                nc = getNationalContest(c.NationalContestNameC, c.NationalContestEdition);
            }
            if (nc != null && getLocalContest(c.NameC, c.NationalContestEdition) == null)
            {
                c.NationalContest = nc;
                c.Edition         = c.NationalContestEdition;
                this._context.LocalContests.Add(c);
                this._context.SaveChanges();
                return(c);
            }
            else
            {
                return(null);
            }
        }