Ejemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] IncidentTask item)
        {
            var errors = IncidentTaskHelper.ValidateClientTaskProperties(item);

            if (errors != null)
            {
                ModelState.AddModelError(errors.Item1, errors.Item2);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            item.Id     = null;
            item.Active = true;
            var taskId = await dataInterface.CreateIncidentTaskAsync(item);

            return(Json(await dataInterface.GetIncidentTaskAsync(taskId)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Update([FromBody] IncidentTask item, string id)
        {
            if (string.IsNullOrWhiteSpace(id) || item == null || id != item.Id)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var errors = IncidentTaskHelper.ValidateClientTaskProperties(item);

            if (errors != null)
            {
                ModelState.AddModelError(errors.Item1, errors.Item2);
            }

            await dataInterface.UpdateIncidentTaskAsync(item);

            return(Ok());
        }