Ejemplo n.º 1
0
        public dynamic Update(SalesInvoice model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.SalesInvoice, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _salesInvoiceService.GetObjectById(model.Id);
                data.DeliveryOrderId = model.DeliveryOrderId;
                data.Description     = model.Description;
                data.Discount        = model.Discount;
                data.IsTaxable       = model.IsTaxable;
                data.InvoiceDate     = model.InvoiceDate;
                data.DueDate         = model.DueDate;
                model = _salesInvoiceService.UpdateObject(data, _deliveryOrderService, _salesInvoiceDetailService);
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors,
                model.AmountReceivable
            }));
        }