예제 #1
0
        public async Task <IActionResult> Create([FromBody] CreateIncidentModel model)
        {
            return(await ProcessAsync(async() =>
            {
                var user = await UserService.GetUserByPrincipal(User);

                var incident = new IncidentModel
                {
                    AcademicYearId = model.AcademicYearId,
                    StudentId = model.StudentId,
                    BehaviourTypeId = model.BehaviourTypeId,
                    Comments = model.Comments,
                    CreatedDate = DateTime.Now,
                    LocationId = model.LocationId,
                    OutcomeId = model.OutcomeId,
                    Points = model.Points,
                    StatusId = model.StatusId,
                    RecordedById = user.Id
                };

                await _incidentService.Create(incident);

                return Ok("Incident created.");
            }, Permissions.Behaviour.Incidents.EditIncidents));
        }
예제 #2
0
        public async Task <IActionResult> Create([FromBody] CreateIncidentModel model)
        {
            try
            {
                var user = await GetLoggedInUser();

                await _behaviourService.CreateIncident(user.Id.Value, model);

                return(Ok());
            }
            catch (Exception e)
            {
                return(HandleException(e));
            }
        }