예제 #1
0
        public int AddBeltEarning(BeltEarningBasic beltEarningBasic)
        {
            try
            {
                BeltEarning beltEarning = new BeltEarning()
                {
                    EarnDate  = beltEarningBasic.EarnDate,
                    StudentId = beltEarningBasic.StudentId,
                    Belt      = beltEarningBasic.Belt,
                    Success   = beltEarningBasic.Success
                };

                Student student = unitOfWork.StudentRepository.GetByID(beltEarningBasic.StudentId);
                if (student != null)
                {
                    student.BeltEarnings.Add(beltEarning);
                }

                unitOfWork.BeltEarningRepository.Insert(beltEarning);
                unitOfWork.Save();

                return(beltEarning.Id);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
예제 #2
0
        public ActionResult AddBeltEarning([FromBody] BeltEarningBasic beltEarningBasic)
        {
            int res = -1;

            res = beltEarningManager.AddBeltEarning(beltEarningBasic);

            if (res != -1)
            {
                return(Ok(res));
            }
            else
            {
                return(BadRequest());
            }
        }