コード例 #1
0
        public ActionResult DeletePatientBill(int id)
        {
            if (id > 0)
            {
                try
                {
                    financeService.DeletePatientBill(id);
                }
                catch (DbUpdateException ex) when((ex.GetBaseException() as SqlException).Number == 547)
                {
                    Program.Logger.Error(ex);
                    return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.foreignConstraintFailed, "Failed", "This field is being used by some other reference. Please delete the reference first before deleting this."))));
                }
                catch (Exception e)
                {
                    Program.Logger.Error(e);
                    return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Error occurred while deleting the patient bill"))));
                }

                return(Ok(GetResponse(ResponseType.ACK, ResponseStatusCode.SUCCESS)));
            }
            else
            {
                return(BadRequest(GetResponse(ResponseType.ERROR, ResponseStatusCode.ERROR, GetError(ErrorCodes.invalidData, "Invalid input", "Please enter proper bill details"))));
            }
        }