public IActionResult Add([FromBody] InternationalContest c)
        {
            dynamic result = new ExpandoObject();

            if (ModelState.IsValid)
            {
                InternationalContest c2 = _repo.addNewInternationalContest(c.Edition);

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


            return(Ok(result));
        }
Exemple #2
0
 public InternationalContest addNewInternationalContest(int Edition)
 {
     try{
         InternationalContest c = new InternationalContest()
         {
             NameC = "IOPS", Edition = Edition
         };
         this._context.InternationalContests.Add(c);
         this._context.SaveChanges();
         return(c);
     }
     catch {
         return(null);
     }
 }
Exemple #3
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);
            }
        }