Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            var flag = await departmentService.GetById(id);

            if (flag == null)
            {
                return(NotFound());
            }

            try
            {
                if (!await departmentService.DeleteCheckOnEntity(id))
                {
                    await departmentService.Delete(id);
                }
                else
                {
                    throw new Exception("ForeignKeys");
                }

                return(Ok());
            }
            catch (Exception ex) { return(InternalServerError(ex)); }
        }