public ActionResult GridUpdateSale([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Sale>(requestData, item => { string error = string.Empty; bool success = true; try { var resultItem = ValidationSales.Find(s => s.ID == item.ID); var index = ValidationSales.IndexOf(resultItem); ValidationSales.Remove(resultItem); ValidationSales.Insert(index, item); } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <Sale> { Error = error, Success = success, Data = item }; }, () => ValidationSales))); }
public ActionResult ProductsUpdate([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Sale>(requestData, sale => { string error = string.Empty; bool success = true; var fSale = SALES.Find(item => item.ID == sale.ID); fSale.Active = sale.Active; fSale.Amount = sale.Amount; fSale.Color = sale.Color; fSale.Country = sale.Country; fSale.Discount = sale.Discount; fSale.End = sale.End; fSale.Amount2 = sale.Amount2; fSale.Start = sale.Start; fSale.Product = sale.Product; fSale.Rank = sale.Rank; return new CollectionViewItemResult <Sale> { Error = error, Success = success, Data = fSale }; }, () => SALES))); }
public ActionResult GridUpdateUserInfo([C1JsonRequest] CollectionViewEditRequest <UserInfo> requestData) { return(this.C1Json(CollectionViewHelper.Edit <UserInfo>(requestData, item => { string error = string.Empty; bool success = true; try { var resultItem = users.Find(u => u.Id == item.Id); var index = users.IndexOf(resultItem); users.Remove(resultItem); users.Insert(index, item); } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <UserInfo> { Error = error, Success = success, Data = item }; }, () => users))); }
//To Delete selected portfolio public ActionResult GridDelete([C1JsonRequest] CollectionViewEditRequest <PortfolioStatic.Portfolio> requestData) { return(this.C1Json(CollectionViewHelper.Edit <PortfolioStatic.Portfolio>(requestData, customer => { string error = string.Empty; bool success = true; try { var result = PortfolioStatic.PortfolioList.FirstOrDefault(item => item.Symbol == customer.Symbol); if (result != null) { PortfolioStatic.PortfolioList.Remove(result); } else { error = "Cannot find the item."; success = false; } } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <PortfolioStatic.Portfolio> { Error = error, Success = success && ModelState.IsValid, Data = customer }; }, () => PortfolioStatic.PortfolioList.ToList <PortfolioStatic.Portfolio>()))); }
public ActionResult GridShowCaseUpdate([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit(requestData, sale => { string error = string.Empty; bool success = true; try { var fSale = model.Find(item => item.ID == sale.ID); fSale.Country = sale.Country; fSale.Amount = sale.Amount; fSale.Start = sale.Start; fSale.End = sale.End; fSale.Product = sale.Product; fSale.Active = sale.Active; fSale.Amount2 = sale.Amount2; fSale.Color = sale.Color; fSale.Discount = sale.Discount; } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <Sale> { Error = error, Success = success, Data = sale }; }, () => model))); }
public ActionResult Delete([C1JsonRequest] CollectionViewEditRequest <Fruit> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Fruit>(requestData, fruit => { string error = string.Empty; bool success = true; var fSale = fruitsSales.Find(item => item.ID == fruit.ID); fruitsSales.Remove(fSale); return new CollectionViewItemResult <Fruit> { Error = error, Success = success, Data = fruit }; }, () => fruitsSales))); }
public ActionResult Create([C1JsonRequest] CollectionViewEditRequest <Fruit> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Fruit>(requestData, fruit => { string error = string.Empty; bool success = true; fruit.ID = GetId(); fruitsSales.Add(fruit); return new CollectionViewItemResult <Fruit> { Error = error, Success = success, Data = fruit }; }, () => fruitsSales))); }
public ActionResult NVGridUpdate([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit(requestData, sale => { string error = string.Empty; bool success = true; var fSale = FlexGridModel.Source.Find(item => item.ID == sale.ID); fSale.Country = sale.Country; fSale.Product = sale.Product; fSale.Amount = sale.Amount; fSale.Discount = sale.Discount; return new CollectionViewItemResult <Sale> { Error = error, Success = success, Data = fSale }; }, () => FlexGridModel.Source))); }
public ActionResult Update([C1JsonRequest] CollectionViewEditRequest <Fruit> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Fruit>(requestData, fruit => { string error = string.Empty; bool success = true; var fSale = fruitsSales.Find(item => item.ID == fruit.ID); fSale.Name = fruit.Name; fSale.Country = fruit.Country; fSale.MayPrice = fruit.MayPrice; fSale.MarPrice = fruit.MarPrice; fSale.AprPrice = fruit.AprPrice; return new CollectionViewItemResult <Fruit> { Error = error, Success = success, Data = fSale }; }, () => fruitsSales))); }
public ActionResult MultiRowEditorsUpdate([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Sale>(requestData, sale => { string error = string.Empty; bool success = true; var fSale = Source.Find(item => item.ID == sale.ID); fSale.Country = sale.Country; fSale.Amount = sale.Amount; fSale.Start = sale.Start; fSale.End = sale.End; fSale.Product = sale.Product; fSale.Active = sale.Active; fSale.Amount2 = sale.Amount2; fSale.Color = sale.Color; return new CollectionViewItemResult <Sale> { Error = error, Success = success && ModelState.IsValid, Data = fSale }; }, () => Source))); }
private ActionResult Delete <T>(CollectionViewEditRequest <T> requestData, DbSet <T> data, Func <T, object> getKey) where T : class { return(this.C1Json(CollectionViewHelper.Edit(requestData, item => { string error = string.Empty; bool success = true; try { T resultItem = null; foreach (var i in data) { if (string.Equals(getKey(i).ToString(), getKey(item).ToString())) { resultItem = i; break; } } if (resultItem != null) { data.Remove(resultItem); _db.SaveChanges(); } } catch (Exception e) { error = GetExceptionMessage(e); success = false; } return new CollectionViewItemResult <T> { Error = error, Success = success, Data = item }; }, () => data.ToList()))); }
//To Update selected portfolio public ActionResult GridUpdate([C1JsonRequest] CollectionViewEditRequest <PortfolioStatic.Portfolio> requestData) { return(this.C1Json(CollectionViewHelper.Edit <PortfolioStatic.Portfolio>(requestData, customer => { string error = string.Empty; bool success = true; try { PortfolioStatic.PortfolioList.Where(x => x.Symbol == customer.Symbol).ToList().ForEach(x => { x.Change = customer.Change; x.Chart = customer.Chart; x.Color = customer.Color; x.Cost = customer.Shares * customer.Price; x.Gain = customer.Price > 0 ? (customer.LastPrice - customer.Price) / customer.Price : 0; x.LastPrice = customer.LastPrice; x.Name = customer.Name; x.Price = customer.Price; x.PriceHistory = customer.PriceHistory; x.Shares = customer.Shares; x.Symbol = customer.Symbol; x.Value = customer.Value; }); } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <PortfolioStatic.Portfolio> { Error = error, Success = success && ModelState.IsValid, Data = customer }; }, () => PortfolioStatic.PortfolioList.ToList <PortfolioStatic.Portfolio>()))); }
private ActionResult Create <T>(CollectionViewEditRequest <T> requestData, DbSet <T> data) where T : class { return(this.C1Json(CollectionViewHelper.Edit <T>(requestData, item => { string error = string.Empty; bool success = true; try { data.Add(item); _db.SaveChanges(); } catch (Exception e) { error = GetExceptionMessage(e); success = false; } return new CollectionViewItemResult <T> { Error = error, Success = success, Data = item }; }, () => data.ToList <T>()))); }
public ActionResult GridCreateUserInfo([C1JsonRequest] CollectionViewEditRequest <UserInfo> requestData) { return(this.C1Json(CollectionViewHelper.Edit <UserInfo>(requestData, item => { string error = string.Empty; bool success = true; try { users.Add(item); item.Id = users.Max(u => u.Id) + 1; } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <UserInfo> { Error = error, Success = success, Data = item }; }, () => users))); }
public ActionResult GridEditorsCreate([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit(requestData, item => { string error = string.Empty; bool success = true; try { Source.Add(item); item.ID = Source.Max(u => u.ID) + 1; } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <Sale> { Error = error, Success = success, Data = item }; }, () => Source))); }
public ActionResult ListUpdateProducts([C1JsonRequest] CollectionViewEditRequest <Product> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Product>(requestData, item => { string error = string.Empty; bool success = true; try { _db.Entry(item as object).State = EntityState.Modified; _db.SaveChanges(); } catch (Exception e) { error = GetExceptionMessage(e); success = false; } return new CollectionViewItemResult <Product> { Error = error, Success = success, Data = item }; }, () => _db.Products.ToList <Product>()))); }
public ActionResult OnPostGridDeleteUserInfo([C1JsonRequest] CollectionViewEditRequest <UserInfo> requestData) { return(JsonConvertHelper.C1Json(CollectionViewHelper.Edit <UserInfo>(requestData, item => { string error = string.Empty; bool success = true; try { var resultItem = Users.Find(u => u.Id == item.Id); Users.Remove(resultItem); } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <UserInfo> { Error = error, Success = success, Data = item }; }, () => Users))); }
public ActionResult MultiRowEditorsDelete([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit(requestData, item => { string error = string.Empty; bool success = true; try { var resultItem = Source.Find(u => u.ID == item.ID); Source.Remove(resultItem); } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <Sale> { Error = error, Success = success, Data = item }; }, () => Source))); }
public ActionResult GridCreateSale([C1JsonRequest] CollectionViewEditRequest <Sale> requestData) { return(this.C1Json(CollectionViewHelper.Edit <Sale>(requestData, item => { string error = string.Empty; bool success = true; try { ValidationSales.Add(item); item.ID = ValidationSales.Max(s => s.ID) + 1; } catch (Exception e) { error = e.Message; success = false; } return new CollectionViewItemResult <Sale> { Error = error, Success = success, Data = item }; }, () => ValidationSales))); }