Esempio n. 1
0
 private void decorateModel(AddEditTaskViewModel input, TaskViewModel model)
 {
     if (input.From == "Field")
     {
         if (model.Task.EntityId <= 0)
         {
             model.Task.Field = _repository.Find <Field>(input.ParentId);
         }
     }
     if (input.From == "Employee")
     {
         if (model.Task.EntityId <= 0)
         {
             var employee = _repository.Find <Employee>(input.ParentId);
             model.SelectedEmployees.Add(new TokenInputDto {
                 id = employee.EntityId, name = employee.FullName
             });
         }
     }
     if (input.From == "Calculator")
     {
         model.Task.Field          = _repository.Find <Field>(input.ParentId);
         model.Product             = input.Product;
         model.Task.QuantityNeeded = input.Quantity;
     }
 }
 private void ShowAddProjectTask(ProjectTask projectTask)
 {
     AddEditTaskViewModel.SetTask(projectTask);
     PopUpViewModel.CurrentViewModel = AddEditTaskViewModel;
     IsPopUpVisible = true;
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
 private void decorateModel(AddEditTaskViewModel input, TaskViewModel model)
 {
     if (input.From == "Field")
     {
         if (model.Task.EntityId <= 0)
             model.Task.Field = _repository.Find<Field>(input.ParentId);
     }
     if (input.From == "Employee")
     {
         if (model.Task.EntityId <= 0)
         {
             var employee = _repository.Find<Employee>(input.ParentId);
             model.SelectedEmployees.Add(new TokenInputDto{id=employee.EntityId,name=employee.FullName});
         }
     }
     if (input.From == "Calculator")
     {
         model.Task.Field = _repository.Find<Field>(input.ParentId);
         model.Product = input.Product;
         model.Task.QuantityNeeded = input.Quantity;
     }
 }
Esempio n. 5
0
 public FormAddTask()
 {
     InitializeComponent();
     m_ViewModel = new AddEditTaskViewModel();
 }
Esempio n. 6
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));
        }