Exemple #1
0
        public ViewData <Instance> GetInstanceByStep(Step step)
        {
            ViewData <Instance> viewData = new ViewData <Instance>();

            if (step.Id == null)
            {
                viewData.StatusCode = FAILTURE;
                return(viewData);
            }
            List <Instance> instances = instanceRepositories.GetSomeInstanceByStepId(step.Id);

            viewData.StatusCode = SUCCESS;
            viewData.SetData(instances);
            return(viewData);
        }
Exemple #2
0
        //for add instance for step
        //stepid is needed
        //暂时不加 查询 stepid 是否存在的情况
        public InstanceView InsertInstanceForStep(Instance instance)
        {
            InstanceView instanceView = new InstanceView();
            bool         result       = false;

            if (instance.stepid == null || instance.Name == null)
            {
                instanceView.StatusCode = FAILTURE;
                return(instanceView);
            }
            //stepRepositories.Update(instance);
            List <Instance> f_instance = instanceRepositories.GetSomeInstanceByStepId(instance.stepid);

            foreach (Instance ins in f_instance)
            {
                if (ins.Name == instance.Name)
                {
                    instanceView.StatusCode = REPETITION;
                    return(instanceView);
                }
            }
            Instance final_instance = instanceRepositories.GetOneInstance(instance.Name, instance.Type);

            final_instance.stepid = instance.stepid;
            result = instanceRepositories.EditIstanceforStep(final_instance);
            if (result)
            {
                Instance        ins_final = instanceRepositories.GetOneInstance(instance.Name, instance.Type);
                List <Instance> list      = new List <Instance>();
                list.Add(ins_final);
                instanceView.StatusCode = SUCCESS;
                instanceView.Data       = list;
                return(instanceView);
            }
            instanceView.StatusCode = FAILTURE;
            return(instanceView);
        }