Exemple #1
0
        // GET: Clazzs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Clazz clazz = db.Clazzs.Find(id);

            if (clazz == null)
            {
                return(HttpNotFound());
            }
            var ListstudentID = clazz.ListStudentId.Split(',').ToList();
            var ListStudent   = new List <ApplicationUser>();

            foreach (var userId in ListstudentID)
            {
                var student = db.Users.Find(userId);
                if (student != null)
                {
                    ListStudent.Add(student);
                }
            }
            ViewData["ListStudent"] = ListStudent;
            return(View(clazz));
        }
Exemple #2
0
        public async Task <IActionResult> PutClazz([FromRoute] string id, [FromBody] Clazz clazz)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != clazz.Id)
            {
                return(BadRequest());
            }

            _context.Entry(clazz).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClazzExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
 public void OnAfterDeserialize()
 {
     if (classType != null && classType != "")
     {
         clazz = (Clazz)Activator.CreateInstance(Assembly.GetExecutingAssembly().GetType(classType));
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("Name,Teacher,Status")] Clazz clazz)
        {
            if (id != clazz.ClazzId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clazz);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClazzExists(clazz.ClazzId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clazz));
        }
Exemple #5
0
        /// <summary>
        /// 对象实体 解析成get 的 XMLObject
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static Dictionary <string, XMLObject> XmlToObjects_get <T>()
        {
            Dictionary <string, XMLObject> dic;

            if (xmlObjecDicCache.TryGetValue(typeof(T).AssemblyQualifiedName, out dic))
            {
                return(dic);
            }
            dic = new Dictionary <string, XMLObject>();
            Dictionary <string, Clazz> clazzDic = ReflectUtils.MethodToFunction <T>();

            foreach (string methodName in clazzDic.Keys)
            {
                Clazz      clazz = clazzDic[methodName];
                MethodInfo m     = clazz.GetMethodInfo;
                if (m == null)
                {
                    continue;
                }
                XMLObject xmlObj = new XMLObject();
                xmlObj.Key = methodName;
                xmlObj.MethodInfos.Add(m);
                xmlObj.MethoedName.Add(m.Name);
                xmlObj.Parameters.Add(null);
                xmlObj.Types.Add(null);
                dic.Add(methodName, xmlObj);
            }
            xmlObjecDicCache.Add(typeof(T).AssemblyQualifiedName, dic);
            return(dic);
        }
Exemple #6
0
        /// <summary>
        /// 单个对象导出 txt
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="path"></param>
        public static void ExportTxt(object obj, string path)
        {
            FileStream   fileStream             = System.IO.File.Create(path);
            StreamWriter streamWriter           = new StreamWriter(fileStream);
            Dictionary <string, Clazz> clazzDic = ReflectUtils.MethodToFunction(obj);
            object value;

            foreach (string methodName in clazzDic.Keys)
            {
                Clazz      clazz = clazzDic[methodName];
                MethodInfo m     = clazz.GetMethodInfo;
                if (m != null)
                {
                    value = m.Invoke(obj, null);
                    if (value != null && !Utils.IsStrNull(value.ToString()))
                    {
                        streamWriter.WriteLine(methodName + "=" + value);
                    }
                }
            }


            streamWriter.Close();
            fileStream.Close();
        }
Exemple #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Clazz clazz = db.Clazzs.Find(id);

            db.Clazzs.Remove(clazz);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #8
0
        public void DestroyingSingletonProviderInvokesPreDestroyMethodsOnSingleton()
        {
            SingletonProvider provider  = new SingletonProvider(typeof(Clazz), injector);
            Clazz             singleton = provider.Apply(null, injector, null) as Clazz;

            provider.Destroy();
            Assert.True(singleton.preDestroyCalled);
        }
Exemple #9
0
        public void ValueProviderReturnsSetValue()
        {
            Clazz         response         = new Clazz();
            ValueProvider provider         = new ValueProvider(response);
            object        returnedResponse = provider.Apply(null, injector, null);

            Assert.AreEqual(response, returnedResponse);
        }
Exemple #10
0
 public ShotResult(Shot shot, Clazz clazz, bool wasAHit, bool wasASink, bool wasFreshDamage)
 {
     this.Shot           = shot;
     this.Class          = clazz;
     this.WasAHit        = wasAHit;
     this.WasASink       = wasASink;
     this.WasFreshDamage = wasFreshDamage;
 }
Exemple #11
0
 /// <summary>
 /// 写入行数据
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="fieldDic"></param>
 /// <param name="row"></param>
 public static void SetRowValue(object obj, Dictionary <int, Clazz> fieldDic, IRow row)
 {
     foreach (int key in fieldDic.Keys)
     {
         Clazz  clazz = fieldDic[key];
         object value = clazz.GetMethodInfo.Invoke(obj, null);
         SetValue(row, key, value);
     }
 }
        public void childInjectorHasMappingWhenExistsOnParentInjector()
        {
            Injector childInjector = injector.CreateChildInjector();
            Clazz    class1        = new Clazz();

            injector.Map(typeof(Clazz)).ToValue(class1);

            Assert.True(childInjector.Satisfies(typeof(Clazz)), "Child injector should return true for satisfies that exists on parent injector");
        }
Exemple #13
0
        public static void ControlToObject(object control, object obj)
        {
            //dynamic obj = type.Assembly.CreateInstance(fullName);
            Dictionary <string, Clazz> clazzDic = ReflectUtils.MethodToFunction(obj);



            object[] parameter = new object[1];
            object   value     = null;

            foreach (string function in clazzDic.Keys)
            {
                Clazz  clazz = clazzDic[function];
                object com   = GetControlObject(function, control);
                if (com is Control)
                {
                    if (!((Control)com).IsEnabled)
                    {
                        continue;
                    }
                }
                if (com != null)
                {
                    if (com is TextBox)
                    {
                        TextBox textBox = (TextBox)com;
                        value = textBox.Text;
                    }
                    else if (com is ComboBox)
                    {
                        ComboBoxItem item = (ComboBoxItem)((ComboBox)com).SelectedItem;
                        value = item.Content;
                    }
                    else if (com is Label)
                    {
                        Label label = (Label)com;
                        value = label.Content;
                    }
                    else if (com is DatePicker)
                    {
                        DatePicker data = (DatePicker)com;
                        value = data.SelectedDate.Value.ToString("yyyy/MM/dd");
                    }
                    else
                    {
                        value = null;
                    }

                    if (value != null)
                    {
                        parameter[0] = value;
                        clazz.SetMethodInfo.Invoke(obj, parameter);
                    }
                }
            }
        }
Exemple #14
0
        public ActionResult Details(int id)
        {
            // 1.准备实体
            Clazz mo = Container.Instance.Resolve <ClazzService>().GetEntity(id);

            // 2.返回视图前预处理

            // 3.返回视图
            return(View(mo));
        }
		public object Apply(Type targetType , Injector activeInjector, Dictionary<string, object> injectParameters)
		{
			lastTargetClassName = targetType.AssemblyQualifiedName;
			object instance = new Clazz ();
			if (PostApply != null)
			{
				PostApply(this, instance);
			}
			return instance;
		}
Exemple #16
0
    public override void CopyFrom(Clazz source)
    {
        var src = source as MyDerivedClass;

        if (src == null)
        {
            return;
        }
        Text = src.Text;
    }
 public IActionResult CreateClazz([FromBody] Clazz clazz, [FromHeader] string Authorization, [FromHeader] string Role)
 {
     if (CheckToken(Authorization) == true && CheckPermission(Role) == true)
     {
         _context.Add(clazz);
         _context.SaveChanges();
         return(Ok());
     }
     return(Unauthorized());
 }
Exemple #18
0
        public override void CopyFrom(Clazz source)
        {
            var src = source as MyNestedClass;

            if (src == null)
            {
                return;
            }
            Number = src.Number;
        }
Exemple #19
0
 public ActionResult Edit([Bind(Include = "ClazzId,ClazzName,ClazzCode,ListStudentId,Description,Status")] Clazz clazz)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clazz).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clazz));
 }
Exemple #20
0
        public object Apply(Type targetType, Injector activeInjector, Dictionary <string, object> injectParameters)
        {
            parameterValue = injectParameters["param"] as string;
            object instance = new Clazz();

            if (PostApply != null)
            {
                PostApply(this, instance);
            }
            return(instance);
        }
Exemple #21
0
        public ActionResult Create([Bind(Include = "ClazzId,ClazzName,ClazzCode,ListStudentId,Description,Status")] Clazz clazz)
        {
            if (ModelState.IsValid)
            {
                db.Clazzs.Add(clazz);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clazz));
        }
        public async Task <IActionResult> Create([Bind("Name,Teacher,Status")] Clazz clazz)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clazz);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clazz));
        }
Exemple #23
0
        public async Task <IActionResult> PostClazz([FromBody] Clazz clazz)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Clazz.Add(clazz);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetClazz", new { id = clazz.Id }, clazz));
        }
Exemple #24
0
 public string Edit(Clazz mo)
 {
     try
     {
         Container.Instance.Resolve <ClazzService>().Edit(mo);
         return("ok");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Exemple #25
0
 private static void SetFeatureBufferValue(IFeatureBuffer featureBuffer, Dictionary <int, Clazz> dic, object obj)
 {
     Dictionary <int, Clazz> .KeyCollection keys = dic.Keys;
     foreach (int current in keys)
     {
         Clazz  clazz = dic[current];
         object value = clazz.GetMethodInfo.Invoke(obj, null);
         if (value != null)
         {
             featureBuffer.set_Value(current, value);
         }
     }
 }
Exemple #26
0
        private void InitStudent()
        {
            #region 生成 1700103001 - 1700103100 学生
            int clazzId;
            for (int i = 1; i <= 100; i++)
            {
                clazzId = new Random().Next(1, 90);
                Container.Instance.Resolve <StudentService>().Create(new Student
                {
                    Name        = "学生" + i,
                    Sex         = i % 2,
                    Clazz       = Container.Instance.Resolve <ClazzService>().GetEntity(clazzId),
                    StudyNumber = "1700103" + i.ToString("000"),
                    Mobile      = "11320" + i.ToString("000000")
                });
            }
            #endregion

            string[] names = { "张三", "李四", "王五" };
            int[]    sexs  = { 0, 1, 0 };
            for (int i = 0; i < names.Length; i++)
            {
                Clazz clazz = Container.Instance.Resolve <ClazzService>().GetEntity(1);

                // 左补0
                string str = (i < 9) ? "0" + (i + 1) : (i + 1).ToString();

                Container.Instance.Resolve <StudentService>().Create(new Student()
                {
                    Name = names[i],
                    Sex  = sexs[i],

                    #region 左补0其它方法
                    // 左补0, 这里最终2位
                    // 1.
                    //StudyNumber = "1700103" + i.ToString().PadLeft(2, '0'),
                    // 2.
                    //StudyNumber = "1700103" + string.Format("{0:d2}", i),
                    // 3.
                    //StudyNumber = "1700103" + i.ToString("00"),
                    // 4.
                    //StudyNumber = "1700103" + i.ToString("D2"),
                    #endregion

                    StudyNumber = str,
                    Mobile      = "15098443993",
                    Clazz       = clazz
                });
            }
        }
Exemple #27
0
        // public Wtemplate[] Children { get; set; }



        public override string ToString()
        {
            return("Template: " + _id
                   + "Clazz: " + Clazz.ToJson()
                   + "RowNum: " + RowNum.ToJson()
                   + "_c: " + _c.ToString()
                   + "_m: " + _m.ToString()
                   + "ActiveFlag: " + ActiveFlag.ToJson()
                   + "Key: " + Key.ToJson()
                   + "Type: " + Type.ToJson()
                   + "Value: " + Value.ToJson()
                   + "TemplateList: " + TemplateList.ToJson()
                   );
        }
Exemple #28
0
        // GET: Clazzs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Clazz clazz = db.Clazzs.Find(id);

            if (clazz == null)
            {
                return(HttpNotFound());
            }
            return(View(clazz));
        }
        public void parentMappedSingletonGetsInitializedByParentWhenInvokedThroughChildInjector()
        {
            Clazz parentClazz = new Clazz();

            injector.Map(typeof(Clazz)).ToValue(parentClazz);
            injector.Map(typeof(ClassInjectee)).AsSingleton();
            Injector childInjector = injector.CreateChildInjector();
            Clazz    childClazz    = new Clazz();

            childInjector.Map(typeof(Clazz)).ToValue(childClazz);

            ClassInjectee classInjectee = childInjector.GetInstance <ClassInjectee>();

            Assert.AreEqual(classInjectee.property, parentClazz, "classInjectee.property is injected with value mapped in parent injector");
        }
        public async Task <MessageModel <string> > Post([FromBody] Clazz Clazz)
        {
            var data = new MessageModel <string>();

            var id = await _iClazzRepository.Add(Clazz);

            data.success = id > 0;
            if (data.success)
            {
                data.response = id.ObjToString();
                data.msg      = "添加成功";
            }

            return(data);
        }