Exemple #1
0
        public static NoteEvaluate ProjectTo(this AddNoteEvaluateRequest request, IMapper mapper)
        {
            NoteEvaluate item = mapper.Map <NoteEvaluate>(request);

            item.DateCreated = DateTime.Now;
            return(item);
        }
        public async override Task AddAsync(object request)
        {
            if (!(request is AddNoteEvaluateRequest))
            {
                throw new Exception("Convert type not allowed");
            }

            AddNoteEvaluateRequest rq = (AddNoteEvaluateRequest)request;
            var item = rq.ProjectTo(_mapper);

            // update student
            await _repository.AddOrUpdateAsync(item);
        }
Exemple #3
0
        public async Task <IHttpActionResult> AddNoteEvaluate([FromBody] AddNoteEvaluateRequest request)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _service.AddAsync(request);

                    await _service.CommitAsync();

                    return(Ok());
                }
                return(BadRequest(ModelState));
            }
            catch (Exception ex)
            {
                await _service.RollbackAsync();

                return(BadRequest(GetError(ex)));
            }
        }