Exemple #1
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            var flag = await officeAssignmentService.GetById(id);

            if (flag == null)
            {
                return(NotFound());
            }
            try
            {
                await officeAssignmentService.Delete(id);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public async Task <IHttpActionResult> Delete(int id)
        {
            var flag = await officeAssignmentService.GetById(id);

            if (flag == null)
            {
                return(NotFound()); // status code 404
            }
            try
            {
                //if (!await courseService.DeleteCheckOnEntity(id))
                await officeAssignmentService.Delete(id);

                //else
                // throw new Exception("ForengKeys");

                return(Ok()); //Sastus code 200
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex)); //Status code 500
            }
        }
Exemple #3
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            var flag = await officeassignmentService.GetById(id);

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

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

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