Пример #1
0
        public ActionResult UpdateEquipmentCenters(EquipmentCenterActionViewModel model)
        {
            List <Center>             centers = new BusinessLayer <Center>(new CapaNavDocDal()).GetList();
            List <Action>             actions = new BusinessLayer <Action>(new CapaNavDocDal()).GetList();
            BusinessLayer <Equipment> bl      = new BusinessLayer <Equipment>(new CapaNavDocDal());
            Equipment equipment = bl.Get(model.EquipmentId.ToInt32());

            equipment.EquipmentCenterActionList = null;

            for (int i = 0; i < centers.Count; i++)
            {
                equipment.EquipmentCenterActionList = actions.Where((t, j) => model.Selections[i][j]).Aggregate(equipment.EquipmentCenterActionList, (current, t) => current.AddIdCouple(centers[i].Id, t.Id));
            }
            bl.Update(equipment);
            return(Json(new { success = true }));
        }
Пример #2
0
        public PartialViewResult GetEquipmentCenters(string id)
        {
            List <Center> centers = new BusinessLayer <Center>(new CapaNavDocDal()).GetList();
            List <Action> actions = new BusinessLayer <Action>(new CapaNavDocDal()).GetList();

            string[] couples = new BusinessLayer <Equipment>(new CapaNavDocDal()).Get(id.ToInt32()).EquipmentCenterActionList?.Split(';') ?? new string[0];
            EquipmentCenterActionViewModel model = new EquipmentCenterActionViewModel
            {
                EquipmentId = id,
                ActionNames = actions.Select(a => a.Description).ToArray(),
                CenterNames = centers.Select(c => c.Name).ToArray(),
                Selections  = ArrayHelper.GetInitialized(centers.Count, actions.Count, (i, j) => couples.Contains($"{centers[i].Id},{actions[j].Id}"))
            };

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