Example #1
0
        public override bool Delete(object model)
        {
            try
            {
                if (model != null)
                {
                    var  wcf       = new WcfService.Service();
                    var  obj       = (PagamentoUnificatoFatturaAcquistoDto)model;
                    bool performed = wcf.DeletePagamentoUnificatoFatturaAcquisto(obj);
                    if (performed) //sync  pagamento
                    {
                        var viewModelPagamento = new Pagamento.PagamentoViewModel();
                        var pagamento          = viewModelPagamento.ReadPagamento(obj);
                        viewModelPagamento.Delete(pagamento);
                    }

                    return(performed);
                }
            }
            catch (Exception ex)
            {
                UtilityError.Write(ex);
            }
            return(false);
        }
Example #2
0
        public override bool Save(object model, bool creating)
        {
            try
            {
                if (model != null)
                {
                    var  wcf       = new WcfService.Service();
                    var  obj       = (PagamentoUnificatoFatturaAcquistoDto)model;
                    bool performed = false;
                    if (creating)
                    {
                        var newObj = wcf.CreatePagamentoUnificatoFatturaAcquisto(obj);
                        performed = (newObj != null);
                        if (performed)
                        {
                            Update(obj, newObj);
                        }
                    }
                    else //updating
                    {
                        performed = wcf.UpdatePagamentoUnificatoFatturaAcquisto(obj);
                    }

                    //sync pagamento
                    if (performed)
                    {
                        var viewModelPagamento = new Pagamento.PagamentoViewModel();
                        var pagamento          = viewModelPagamento.ReadPagamento(obj);
                        creating = (pagamento == null);
                        if (creating)
                        {
                            pagamento = BusinessLogic.Pagamento.GetNewPagamento(obj);
                        }

                        var pagamentoOld = viewModelPagamento.ReadPagamento(pagamentoUnificatoOld, fatturaAcquistoOld);
                        if (pagamentoOld != null && pagamento != null && pagamentoOld.Id != pagamento.Id)
                        {
                            viewModelPagamento.Delete(pagamentoOld);
                        }
                        performed = viewModelPagamento.Save(pagamento, creating);
                    }
                    return(performed);
                }
            }
            catch (Exception ex)
            {
                UtilityError.Write(ex);
            }
            return(false);
        }