Exemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] CreateAssignmentDto assignment)
        {
            var newAssignment = _mapper.Map <Assignment>(assignment);
            var result        = await _repository.Create(newAssignment);

            return(CreatedAtAction(nameof(FindById), new { id = result.Id }, _mapper.Map <AssignmentDto>(result)));
        }
Exemplo n.º 2
0
        public Assignment Create(AssignmentViewModel assignment)
        {
            Assignment newAssignment = new Assignment()
            {
                Title       = assignment.Title,
                Description = assignment.Description,
                Course      = assignment.Course
            };

            return(_assignmentRepository.Create(newAssignment));
        }
Exemplo n.º 3
0
        public async Task <GenericResponseMessage> Create(Assignment assignment)
        {
            var response = new GenericResponseMessage();

            try
            {
                await _assignmentRepository.Create(assignment);

                response.IsSuccessful = true;
                response.Message      = "Successfully created assignment.";
            }
            catch (Exception)
            {
                response.IsSuccessful = false;
                response.Message      = $"Could not delete assignment.";
            }

            return(response);
        }
        public ActionResult <bool> Post([FromBody] Assignment newAssignment)
        {
            repo.Create(newAssignment);

            return(true);
        }