Exemple #1
0
        public ActionResult CreateUser()
        {
            var administrations = new List <SelectListItem>();
            var paymentTypes    = new List <SelectListItem>();
            var ownershipList   = new List <SelectListItem>();

            if (AdministrationService.GetAll() != null)
            {
                administrations = this.AdministrationService.GetAll().Select(x => new SelectListItem()
                {
                    Value = x.Id.ToString(),
                    Text  = x.Name
                }).ToList();
            }

            if (PaymentTypeService.GetAll() != null)
            {
                paymentTypes = this.PaymentTypeService.GetAll().Select(x => new SelectListItem()
                {
                    Value = x.Id.ToString(),
                    Text  = x.Description
                }).ToList();
            }

            var ownerships = OwnershipService.GetAll();


            if (ownerships.Count > 0)
            {
                ownerships.ForEach(x =>
                {
                    if (x.Address != null)
                    {
                        ownershipList.Add(new SelectListItem()
                        {
                            Value = x.Id.ToString(),
                            Text  = x.Address.Street + " " + x.Address.Number
                        });
                    }
                });

                ownershipList.OrderBy(x => x.Text).ToList();
            }

            var functionalUnitList = new List <FunctionalUnit>().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text  = x.Ownership.Address.Street + " " + x.Ownership.Address.Number
            });

            var userViewModel = new UserViewModel()
            {
                Administrations = administrations, PaymentTypes = paymentTypes, OwnershipList = ownershipList, FunctionalUnitList = functionalUnitList, IsOwner = true
            };

            return(View(userViewModel));
        }
        private void FillDropDown()
        {
            ddlBranch.DataSource     = BranchService.GetActiveBranches(User.Identity.Name);
            ddlBranch.DataTextField  = "Name";
            ddlBranch.DataValueField = "ID";
            ddlBranch.DataBind();
            //ddlBranch.Enabled = ddlBranch.Items.Count > 0;

            ddlPaymentType.DataSource     = PaymentTypeService.GetAll();
            ddlPaymentType.DataTextField  = "Description";
            ddlPaymentType.DataValueField = "ID";
            ddlPaymentType.DataBind();

            ddlBranch_SelectedIndexChanged(null, null);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                calInvoiceDate.SelectedDate = DateTime.Today;
                calPaymentDate.SelectedDate = DateTime.Today;
                string invoiceNo = Request["InvoiceNo"];
                LoadInvoice(invoiceNo);

                ddlPaymentType.DataSource     = PaymentTypeService.GetAll();
                ddlPaymentType.DataTextField  = "Description";
                ddlPaymentType.DataValueField = "ID";
                ddlPaymentType.DataBind();

                ddlItemType.DataSource     = ItemTypeService.GetAll();
                ddlItemType.DataTextField  = "Description";
                ddlItemType.DataValueField = "ID";
                ddlItemType.DataBind();
            }
        }