Ejemplo n.º 1
0
        private IEnumerable <TInvoiceViewModel> ConvertToTInvoices(TInvoice invoice)
        {
            TInvoiceViewModel inv = new TInvoiceViewModel
            {
                //ProjectId = entity.ProjectId != null ? entity.ProjectId.Id : string.Empty,
                ProjectName       = invoice.ProjectId != null ? invoice.ProjectId.ProjectName : string.Empty,
                ProjectSpkNo      = invoice.ProjectId != null ? invoice.ProjectId.ProjectSpkNo : string.Empty,
                CustomerName      = invoice.ProjectId != null ? invoice.ProjectId.CustomerId.CustomerName : string.Empty,
                CustomerAddress   = invoice.ProjectId != null ? invoice.ProjectId.CustomerId.CustomerAddress : string.Empty,
                InvoicePeriod     = invoice.InvoicePeriod,
                InvoiceStartDate  = invoice.InvoiceStartDate,
                InvoiceEndDate    = invoice.InvoiceEndDate,
                InvoiceNo         = invoice.InvoiceNo,
                InvoiceDate       = invoice.InvoiceDate,
                InvoiceLastStatus = invoice.InvoiceLastStatus,
                InvoicePaidDate   = invoice.InvoicePaidDate,
                //InvoiceValue = invoice.InvoiceValue,
                //InvoiceRetention = invoice.InvoiceRetention,
                //InvoicePpn = invoice.InvoicePpn,
                //InvoiceTotal = invoice.InvoiceTotal,
                InvoiceId = invoice.Id
            };
            IList <TInvoiceViewModel> list = new List <TInvoiceViewModel>();

            list.Add(inv);
            return(list);
        }
        private void ConvertToTInvoice(TInvoiceViewModel vm, TInvoice entity, string ParentProjectId)
        {
            entity.ProjectId = string.IsNullOrEmpty(ParentProjectId) ? null : _TProjectTasks.One(ParentProjectId);

            entity.InvoicePeriod     = new DateTime(vm.InvoicePeriod.Value.Year, vm.InvoicePeriod.Value.Month, 1);
            entity.InvoiceStartDate  = vm.InvoiceStartDate;
            entity.InvoiceEndDate    = vm.InvoiceEndDate;
            entity.InvoiceNo         = vm.InvoiceNo;
            entity.InvoiceDate       = vm.InvoiceDate;
            entity.InvoiceLastStatus = vm.InvoiceLastStatus;
            entity.InvoicePaidDate   = vm.InvoicePaidDate;
            //entity.InvoiceValue = vm.InvoiceValue;
            //entity.InvoiceRetention = vm.InvoiceRetention;
            //entity.InvoicePpn = vm.InvoicePpn;
            //entity.InvoiceTotal = vm.InvoiceTotal;
        }
        public ActionResult TInvoices_Update([DataSourceRequest] DataSourceRequest request, TInvoiceViewModel vm, string ParentProjectId)
        {
            if (vm != null && ModelState.IsValid)
            {
                var entity = _tasks.One(vm.InvoiceId);
                if (entity != null)
                {
                    ConvertToTInvoice(vm, entity, ParentProjectId);

                    entity.ModifiedDate = DateTime.Now;
                    entity.ModifiedBy   = User.Identity.Name;
                    entity.DataStatus   = EnumDataStatus.Updated.ToString();

                    _tasks.Update(entity);
                }
            }

            return(Json(ModelState.ToDataSourceResult()));
        }
        public ActionResult TInvoices_Create([DataSourceRequest] DataSourceRequest request, TInvoiceViewModel vm, string ParentProjectId)
        {
            if (vm != null && ModelState.IsValid)
            {
                TInvoice entity = new TInvoice();
                entity.SetAssignedIdTo(Guid.NewGuid().ToString());

                ConvertToTInvoice(vm, entity, ParentProjectId);

                entity.CreatedDate = DateTime.Now;
                entity.CreatedBy   = User.Identity.Name;
                entity.DataStatus  = EnumDataStatus.New.ToString();

                _tasks.Insert(entity);
            }

            return(Json(new[] { vm }.ToDataSourceResult(request, ModelState)));
        }