コード例 #1
0
        public override void Update(BllControl entity)
        {
            ResultLibService resultLibService = new ResultLibService(uow);

            resultLibService.Update(entity.ResultLib);
            EquipmentLibService equipmentLibService = new EquipmentLibService(uow);

            equipmentLibService.Update(entity.EquipmentLib);
            uow.Controls.Update(mapper.MapToDal(entity));
            ControlMethodDocumentationLibService controlMethodDocumentationLibService = new ControlMethodDocumentationLibService(uow);

            controlMethodDocumentationLibService.Update(entity.ControlMethodDocumentationLib);
            RequirementDocumentationLibService requirementDocumentationLibService = new RequirementDocumentationLibService(uow);

            requirementDocumentationLibService.Update(entity.RequirementDocumentationLib);
            EmployeeLibService employeeLibService = new EmployeeLibService(uow);

            employeeLibService.Update(entity.EmployeeLib);
            uow.Commit();
        }
コード例 #2
0
        public new BllControl Create(BllControl entity)
        {
            ImageLibService     imageLibService     = new ImageLibService(uow);
            EquipmentLibService equipmentLibService = new EquipmentLibService(uow);
            ControlMethodDocumentationLibService controlMethodDocumentationLibService = new ControlMethodDocumentationLibService(uow);
            RequirementDocumentationLibService   requirementDocumentationLibService   = new RequirementDocumentationLibService(uow);
            EmployeeLibService employeeLibService = new EmployeeLibService(uow);
            ResultLibService   resultLibService   = new ResultLibService(uow);

            var imageLib = imageLibService.Create(entity.ImageLib);

            entity.ImageLib     = imageLib;
            entity.EquipmentLib = equipmentLibService.Create(entity.EquipmentLib);
            entity.ControlMethodDocumentationLib = controlMethodDocumentationLibService.Create(entity.ControlMethodDocumentationLib);
            entity.RequirementDocumentationLib   = requirementDocumentationLibService.Create(entity.RequirementDocumentationLib);
            entity.EmployeeLib = employeeLibService.Create(entity.EmployeeLib);
            entity.ResultLib   = resultLibService.Create(entity.ResultLib);

            return(entity);
        }
コード例 #3
0
        //public override BllControlMethodsLib Get(int id)
        //{
        //    var retElement = bllMapper.MapToBll(uow.ControlMethodsLibs.Get(id));

        //    return retElement;
        //}

        public new BllControlMethodsLib Update(BllControlMethodsLib entity, bool isTemplate)
        {
            IControlMapper controlMapper = new ControlMapper(uow);

            foreach (var Control in entity.Entities)
            {
                var currentControl = Control;
                if (Control.Id == 0)
                {
                    ControlService service = new ControlService(uow);
                    currentControl = service.Create(Control);
                    var dal = controlMapper.MapToDal(currentControl);
                    dal.Lib_id = entity.Id;
                    var ormControl = uow.Controls.Create(dal, isTemplate);
                    uow.Commit();
                    Control.Id             = ormControl.id;
                    Control.ProtocolNumber = ormControl.protocolNumber;
                }
                else
                {
                    var dalControl = controlMapper.MapToDal(currentControl);
                    dalControl.Lib_id = entity.Id;

                    ImageLibService imageLibService = new ImageLibService(uow);
                    Control.ImageLib = imageLibService.Update(Control.ImageLib);
                    EquipmentLibService equipmentLibService = new EquipmentLibService(uow);
                    Control.EquipmentLib = equipmentLibService.Update(Control.EquipmentLib);
                    ResultLibService resultLibService = new ResultLibService(uow);
                    Control.ResultLib = resultLibService.Update(Control.ResultLib);
                    RequirementDocumentationLibService reqDocLibService = new RequirementDocumentationLibService(uow);
                    Control.RequirementDocumentationLib = reqDocLibService.Update(Control.RequirementDocumentationLib);
                    ControlMethodDocumentationLibService methodDocLibService = new ControlMethodDocumentationLibService(uow);
                    Control.ControlMethodDocumentationLib = methodDocLibService.Update(Control.ControlMethodDocumentationLib);
                    EmployeeLibService employeeLibService = new EmployeeLibService(uow);
                    Control.EmployeeLib = employeeLibService.Update(Control.EmployeeLib);
                    uow.Controls.Update(dalControl);
                }
            }

            var ControlsWithLibId = ((IGetterByLibId <DalControl>)entityRepository).GetEntitiesByLibId(entity.Id);

            foreach (var Control in ControlsWithLibId)
            {
                bool isTrashControl = true;
                foreach (var control in entity.Entities)
                {
                    if (control.Id == Control.Id)
                    {
                        isTrashControl = false;
                        break;
                    }
                }
                if (isTrashControl == true)
                {
                    uow.Controls.Delete(Control.Id);
                }
            }

            uow.Commit();

            return(entity);
        }