public SelectBoxPickerDto GetPickerDto <ENTITY>(IEnumerable <ENTITY> selectedItems, Expression <Func <ENTITY, object> > text, Expression <Func <ENTITY, object> > value, bool softDelete = false) where ENTITY : DomainEntity
        {
            var allItems       = _selectListItemService.CreateList(text, value, false, softDelete).ToList();
            var _selectedItems = _selectListItemService.CreateList(selectedItems, text, value, false);

            _selectedItems.Each(x =>
            {
                var availableListItem = allItems.FirstOrDefault(a => a.Text == x.Text && a.Value == x.Value);
                if (availableListItem != null)
                {
                    allItems.Remove(availableListItem);
                }
            });
            return(new SelectBoxPickerDto
            {
                SelectedListItems = _selectedItems.ToList(),
                AvailableListItems = allItems,
                EntityTypeName = typeof(ENTITY).Name
            });
        }
示例#2
0
        public ActionResult AddUpdate(ViewModel input)
        {
            var document      = input.EntityId > 0 ? _repository.Find <Document>(input.EntityId) : new Document();
            var categoryItems = _selectListItemService.CreateList <DocumentCategory>(x => x.Name, x => x.EntityId, true);
            var model         = new DocumentViewModel
            {
                Document             = document,
                DocumentCategoryList = categoryItems
            };

            return(View(model));
        }
        public ActionResult AddUpdate(ViewModel input)
        {
            var photo         = input.EntityId > 0 ? _repository.Find <Photo>(input.EntityId) : new Photo();
            var categoryItems = _selectListItemService.CreateList <PhotoCategory>(x => x.Name, x => x.EntityId, true);
            var model         = new PhotoViewModel
            {
                Photo             = photo,
                PhotoCategoryList = categoryItems
            };

            return(View(model));
        }
示例#4
0
        public CalculatorViewModel GetViewModel()
        {
            var fieldItems = _selectListItemService.CreateList <Field>(x => x.Name, x => x.EntityId, true, true);

            return(new MaterialsCalcViewModel
            {
                FieldList = fieldItems,
                CalculatorDisplayName = WebLocalizationKeys.MATERIALS.ToString(),
                CalculatorName = WebLocalizationKeys.MATERIALS.ToString(),
                CalculateUrl = UrlContext.GetUrlForAction <CalculatorController>(x => x.Calculate(null)),
                SaveJSSuccssCallback = "kyt.calculator.controller.materialsSuccess"
            });
        }
        public ActionResult AddEdit(AddEditEventViewModel input)
        {
            var _event = input.EntityId > 0 ? _repository.Find <Event>(input.EntityId) : new Event();

            _event.ScheduledDate = input.ScheduledDate.HasValue ? input.ScheduledDate.Value : _event.ScheduledDate;
            _event.StartTime     = input.StartTime.HasValue ? input.StartTime.Value : _event.StartTime;
            var fields      = _selectListItemService.CreateList <Field>(x => x.Name, x => x.EntityId, true, true);
            var _eventTypes = _selectListItemService.CreateList <EventType>(x => x.Name, x => x.EntityId, true);
            var model       = new EventViewModel
            {
                FieldList     = fields,
                EventTypeList = _eventTypes,
                Event         = _event,
                Copy          = input.Copy,
            };

            if (_event.EntityId > 0)
            {
                model.Field     = _event.Field.EntityId;
                model.EventType = _event.EventType.EntityId;
            }
            return(PartialView("EventAddUpdate", model));
        }
示例#6
0
        public CalculatorViewModel GetViewModel()
        {
            var products     = _repository.Query <InventoryProduct>(x => x.Product.InstantiatingType == "Seed");
            var productItems = _selectListItemService.CreateListWithConcatinatedText(products, x => x.Product.Name, x => x.UnitType, " --> ", x => x.EntityId, true);
            var fieldItems   = _selectListItemService.CreateList <Field>(x => x.Name, x => x.EntityId, true, true);

            return(new OverseedBagsNeededCalcViewModel
            {
                FieldList = fieldItems,
                ProductList = productItems,
                CalculatorDisplayName = WebLocalizationKeys.OVERSEED_BAGS_NEEEDED_DISPLAY.ToString(),
                CalculatorName = WebLocalizationKeys.OVERSEED_BAGS_NEEEDED.ToString(),
                CalculateUrl = UrlContext.GetUrlForAction <CalculatorController>(x => x.Calculate(null)),
                SaveJSSuccssCallback = "kyt.calculator.controller.overseedBagsNeededSuccess"
            });
        }
        public ActionResult EmailJob(ViewModel input)
        {
            var emailJob = input.EntityId > 0 ? _repository.Find <EmailJob>(input.EntityId) : new EmailJob();

            emailJob.Status = input.EntityId > 0 ? emailJob.Status : Status.InActive.ToString();
            var emailTemplates = _selectListItemService.CreateList <EmailTemplate>(x => x.Name, x => x.EntityId, true);
            var selectorDto    = _selectBoxPickerService.GetPickerDto(emailJob.GetSubscribers().OrderBy(x => x.FullName), x => x.FullName, x => x.EntityId);
            var model          = new EmailJobViewModel
            {
                EmailJob = emailJob,
                UserSelectBoxPickerDto = selectorDto,
                EmailTemplateList      = emailTemplates
            };

            return(PartialView("EmailJobAddUpdate", model));
        }
示例#8
0
        public ActionResult AddEdit(ViewModel input)
        {
            var             purchaseOrder = input.ParentId > 0 ? _repository.Find <PurchaseOrder>(input.ParentId) : new PurchaseOrder();
            var             vendors       = _selectListItemService.CreateList <Vendor>(x => x.Company, x => x.EntityId, true);
            var             url           = UrlContext.GetUrlForAction <PurchaseOrderController>(x => x.Products(null)) + "?Vendor=0";
            var             PoliUrl       = UrlContext.GetUrlForAction <PurchaseOrderLineItemListController>(x => x.PurchaseOrderLineItems(null)) + "?EntityId=" + purchaseOrder.EntityId;
            POListViewModel model         = new POListViewModel()
            {
                PurchaseOrder = purchaseOrder,
                VendorList    = vendors,
                VendorId      = purchaseOrder.EntityId > 0 ? purchaseOrder.Vendor.EntityId : 0,
                ReturnUrl     = UrlContext.GetUrlForAction <PurchaseOrderListController>(x => x.PurchaseOrderList()),
                CommitUrl     = UrlContext.GetUrlForAction <PurchaseOrderCommitController>(x => x.PurchaseOrderCommit(null)),

                ListDefinition     = _purchaseOrderSelectorGrid.GetGridDefinition(url, WebLocalizationKeys.PRODUCTS),
                PoliListDefinition = _purchaseOrderLineItemGrid.GetGridDefinition(PoliUrl, WebLocalizationKeys.PURCHASE_ORDER_LINE_ITEMS)
            };

            return(PartialView("PurchaseOrderBuilder", model));
        }
示例#9
0
        public ActionResult AddEdit(AddEditTaskViewModel input)
        {
            var task = input.EntityId > 0 ? _repository.Find <Task>(input.EntityId) : new Task();

            task.ScheduledDate      = input.ScheduledDate.HasValue ? input.ScheduledDate.Value : task.ScheduledDate;
            task.ScheduledStartTime = input.ScheduledStartTime.HasValue ? input.ScheduledStartTime.Value: task.ScheduledStartTime;
            var fields    = _selectListItemService.CreateList <Field>(x => x.Name, x => x.EntityId, true, true);
            var taskTypes = _selectListItemService.CreateList <TaskType>(x => x.Name, x => x.EntityId, true);

            var dictionary = new Dictionary <string, IEnumerable <SelectListItem> >();
            IEnumerable <InventoryProduct> inventory = _repository.FindAll <InventoryProduct>();
            var chemicals = _selectListItemService.CreateListWithConcatinatedText(inventory.Where(i => i.Product.InstantiatingType == "Chemical"),
                                                                                  x => x.Product.Name,
                                                                                  x => x.UnitType,
                                                                                  "-->",
                                                                                  y => y.EntityId,
                                                                                  false);
            var fertilizer = _selectListItemService.CreateListWithConcatinatedText(inventory.Where(i => i.Product.InstantiatingType == "Fertilizer"),
                                                                                   x => x.Product.Name,
                                                                                   x => x.UnitType,
                                                                                   "-->",
                                                                                   x => x.EntityId,
                                                                                   false);
            var materials = _selectListItemService.CreateListWithConcatinatedText(inventory.Where(i => i.Product.InstantiatingType == "Material"),
                                                                                  x => x.Product.Name,
                                                                                  x => x.UnitType,
                                                                                  "-->",
                                                                                  x => x.EntityId,
                                                                                  false);
            var seeds = _selectListItemService.CreateListWithConcatinatedText(inventory.Where(i => i.Product.InstantiatingType == "Seed"),
                                                                              x => x.Product.Name,
                                                                              x => x.UnitType,
                                                                              "-->",
                                                                              x => x.EntityId,
                                                                              false);

            dictionary.Add(WebLocalizationKeys.CHEMICALS.ToString(), chemicals);
            dictionary.Add(WebLocalizationKeys.MATERIALS.ToString(), materials);
            dictionary.Add(WebLocalizationKeys.FERTILIZERS.ToString(), fertilizer);
            dictionary.Add(WebLocalizationKeys.SEEDS.ToString(), seeds);
            var availableEmployees = _repository.FindAll <Employee>().Select(x => new TokenInputDto {
                id = x.EntityId, name = x.FullName
            });
            var selectedEmployees = task.GetEmployees().Select(x => new TokenInputDto {
                id = x.EntityId, name = x.FullName
            });
            var availableEquipment = _repository.FindAll <Equipment>().Select(x => new TokenInputDto {
                id = x.EntityId, name = x.Name
            });
            var selectedEquipment = task.GetEquipment().Select(x => new TokenInputDto {
                id = x.EntityId, name = x.Name
            });

            var model = new TaskViewModel
            {                //strangly I have to itterate this or NH freaks out
                AvailableEmployees = availableEmployees.ToList(),
                SelectedEmployees  = selectedEmployees.ToList(),
                AvailableEquipment = availableEquipment.ToList(),
                SelectedEquipment  = selectedEquipment,
                FieldList          = fields,
                ProductList        = dictionary,
                TaskTypeList       = taskTypes,
                Task = task,
            };

            if (task.EntityId > 0)
            {
                model.Product = task.GetProductIdAndName();
            }
            decorateModel(input, model);
            if (input.Copy)
            {
                model.Task.EntityId = 0;
                model.Task.Complete = false;
            }

            return(PartialView("TaskAddUpdate", model));
        }