예제 #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)));
        }
예제 #2
0
        public Assignment Create(AssignmentViewModel assignment)
        {
            Assignment newAssignment = new Assignment()
            {
                Title       = assignment.Title,
                Description = assignment.Description,
                Course      = assignment.Course
            };

            return(_assignmentRepository.Create(newAssignment));
        }
예제 #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);
        }