Example #1
0
        public override void SetModel(dynamic entity)
        {
            Projects data = (Projects)entity;

            BindingFromModel(data, this);
            ProjectContract.Query(data.Id);

            if (data.SupplierTranscationItem.Any())
            {
                foreach (var row in data.SupplierTranscationItem)
                {
                    SuppliersViewModel model = new SuppliersViewModel();
                    model.ProjectId      = row.ProjectId;
                    model.PlaceofReceipt = row.PlaceofReceipt;

                    if (row.ManufacturersBussinessItems != null)
                    {
                        model.ManufacturersName     = row.ManufacturersBussinessItems.Manufacturers.Name;
                        model.TicketPeriod          = row.ManufacturersBussinessItems.TicketPeriod.Name;
                        model.MaterialCategories    = row.ManufacturersBussinessItems.MaterialCategories.Name;
                        model.PaymentTypeName       = row.ManufacturersBussinessItems.PaymentTypes.PaymentTypeName;
                        model.TranscationCategories = row.ManufacturersBussinessItems.TranscationCategories.Name;
                    }

                    model.SetModel(row.ManufacturersBussinessItems);
                    Suppliers.Add(model);
                }
            }
        }
Example #2
0
        public void Query(Guid ProjectId)
        {
            try
            {
                var QueryResult = _projectcontroller.Query(p => p.Id == ProjectId);

                if (!QueryResult.HasError)
                {
                    var data = QueryResult.Result.SingleOrDefault();
                    BindingFromModel(data, this);

                    if (data.ClientId.HasValue)
                    {
                        Client.QueryModel(data.ClientId.Value);
                    }

                    if (data.SupplierTranscationItem.Any())
                    {
                        Suppliers.Clear();
                        foreach (var row in data.SupplierTranscationItem)
                        {
                            SuppliersViewModel model = new SuppliersViewModel();
                            try
                            {
                                model.ProjectId             = row.ProjectId;
                                model.PlaceofReceipt        = row.PlaceofReceipt;
                                model.ManufacturersName     = row.ManufacturersBussinessItems.Manufacturers.Name;
                                model.TicketPeriod          = row.ManufacturersBussinessItems.TicketPeriod.Name;
                                model.MaterialCategories    = row.ManufacturersBussinessItems.MaterialCategories.Name;
                                model.PaymentTypeName       = row.ManufacturersBussinessItems.PaymentTypes.PaymentTypeName;
                                model.TranscationCategories = row.ManufacturersBussinessItems.TranscationCategories.Name;
                                model.SetModel(row.ManufacturersBussinessItems);
                            }
                            catch (Exception ex)
                            {
                                setErrortoModel(model, ex);
                            }

                            if (!model.HasError)
                            {
                                Suppliers.Add(model);
                            }
                        }
                    }

                    if (data.ProjectContract.Any())
                    {
                        ProjectContract.Clear();
                        foreach (var row in data.ProjectContract)
                        {
                            ProjectContractViewModel model = new ProjectContractViewModel();
                            model.SetModel(row);
                            ProjectContract.Add(model);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                setErrortoModel(this, ex);
            }
        }