public async Task <MainResponse> AddClassResult(AddClassResultRequest addClassResultRequest, string actionBy)
        {
            var resultCheck = _resultRepository.GetSingle(x => x.ClassId == addClassResultRequest.ClassId && x.ExhibitorId == addClassResultRequest.ExhibitorId &&
                                                          x.IsActive == true && x.IsDeleted == false);

            if (resultCheck != null)
            {
                _mainResponse.Message = Constants.RECORD_AlREADY_EXIST;
                _mainResponse.Success = false;
                return(_mainResponse);
            }
            var ageGroup = _classRepository.GetSingle(x => x.ClassId == addClassResultRequest.ClassId);

            var addResult = new Result
            {
                ClassId     = addClassResultRequest.ClassId,
                AgeGroup    = ageGroup.AgeGroup,
                ExhibitorId = addClassResultRequest.ExhibitorId,
                Placement   = addClassResultRequest.Place,
                IsActive    = true,
                CreatedBy   = actionBy,
                CreatedDate = DateTime.Now
            };

            await _resultRepository.AddAsync(addResult);

            _mainResponse.Message = Constants.CLASS_RESULT_ADDED;
            _mainResponse.Success = true;
            return(_mainResponse);
        }
Exemple #2
0
        public async Task <IActionResult> AddClassResult(AddClassResultRequest addClassResultRequest)
        {
            string actionBy = User.Identity.Name;

            _mainResponse = await _classService.AddClassResult(addClassResultRequest, actionBy);

            _jsonString = Mapper.Convert <BaseResponse>(_mainResponse);
            return(new OkObjectResult(_jsonString));
        }
        public async Task <MainResponse> AddClassResult(AddClassResultRequest addClassResultRequest, string actionBy)
        {
            var ageGroup = _classRepository.GetSingle(x => x.ClassId == addClassResultRequest.ClassId);

            var addResult = new Result
            {
                ClassId     = addClassResultRequest.ClassId,
                AgeGroup    = ageGroup.AgeGroup,
                ExhibitorId = addClassResultRequest.ExhibitorId,
                HorseId     = addClassResultRequest.HorseId,
                Placement   = addClassResultRequest.Place,
                IsActive    = true,
                CreatedBy   = actionBy,
                CreatedDate = DateTime.Now
            };

            await _resultRepository.AddAsync(addResult);

            _mainResponse.Message = Constants.CLASS_RESULT_ADDED;
            _mainResponse.Success = true;
            return(_mainResponse);
        }