Example #1
0
        public virtual CommonResponse Delete(string id)
        {
            try
            {
                var result = false;
                if (id.Contains(","))
                {
                    result = _service.BatchDelete(id);
                }
                else
                {
                    result = _service.Delete(int.Parse(id));
                }

                return(new CommonResponse()
                {
                    code = result ? (int)ResponseCode.OK : (int)ResponseCode.BadRequest,
                    data = new
                    {
                        success = result
                    }
                });
            }
            catch (Exception e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("conflict"))
                {
                    return(new CommonResponse()
                    {
                        code = (int)ResponseCode.Conflict,
                        data = new
                        {
                            success = false,
                            message = e.Message
                        }
                    });
                }
                else
                {
                    throw e;
                }
            }
        }