Пример #1
0
        public async Task <HttpResponseMessage> DeleteInvoices([FromBody] string strIds)
        {
            var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

            string failurs = "";

            string[] values = strIds.Split(',');
            for (int i = 0; i < values.Length - 1; i++)
            {
                var id = Convert.ToInt32(values[i].Trim());

                DocumentRule   documentRule    = new DocumentRule();
                PayRecevieRule payRecevieRule  = new PayRecevieRule();
                var            payRecevieQuery = await payRecevieRule.GetByInvoiceIdAsync(id);

                if (payRecevieQuery.Any())
                {
                    failurs += "<br/>" + "برای این فاکنور دریافت/ پرداخت انجام شده است برای حذف باید دریافت و پرداخت حذف گردد.";
                }
                else
                {
                    await Rule.DeleteAsync(id);

                    await this.BusinessRule.UnitOfWork.SaveChangesAsync();
                }
            }



            if (!string.IsNullOrEmpty(failurs))
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.ValidationError, data = failurs }));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.Successful, data = "" }));
            }
        }