public async Task <IActionResult> EditerT(int id) { var product = await db.GetProductInfoAsync(id); var timer = new Stopwatch(); timer.Start(); if (getProperties == null) { var type = Expression.Parameter(typeof(Type), "type"); var methods = typeof(Type).GetMethods(); var method = methods.Where(m => m.Name == "GetProperties").FirstOrDefault(); var props = Expression.Call(type, method, new Expression[0]); var lambda = Expression.Lambda <Func <Type, PropertyInfo[]> >(props, type); getProperties = lambda.Compile(); } var properties = getProperties(typeof(ProductInfo)); var model = new EditerTModel(); model.Types = properties .Select(property => Tuple.Create(property.Name, property, property.GetCustomAttribute(typeof(Attributes.ClassName)) != null)) .ToArray(); model.StandartValues = new object[model.Types.Length]; for (int i = 0; i < model.Types.Length; i++) { model.StandartValues[i] = model.Types[i].Item2.GetValue(product); } timer.Stop(); model.TimeInTicks = timer.ElapsedTicks; return(View(model)); }
public async Task <IActionResult> EditT(EditerTModel model) { return(RedirectToAction("Index")); }