public BulkPurchaseForex Save(BulkPurchaseForex model, string action) { ActionMode mode = (ActionMode)Enum.Parse(typeof(ActionMode), action, true); switch (mode) { case ActionMode.Add: BulkPurchaseForexViewModel.Current.AddItem(model); return(model); case ActionMode.Edit: var forex = BulkPurchaseForexViewModel.Current; forex.Remove(forex.Where(i => i.Id == model.Id).FirstOrDefault()); forex.AddItem(model); BulkPurchaseForexViewModel.Current = forex; return(model); case ActionMode.Delete: var removeforex = BulkPurchaseForexViewModel.Current; removeforex.Remove(removeforex.Where(i => i.Id == model.Id).FirstOrDefault()); BulkPurchaseForexViewModel.Current = removeforex; return(model); //case ActionMode.Cancel: // break; default: break; } return(null); }
private BulkPurchaseForex FindById(int?id = 0) { BulkPurchaseForex row = new BulkPurchaseForex(); if (id > 0) { var forex = BulkPurchaseForexViewModel.Current; row = forex.Where(f => f.Id == id).Select(f => f).FirstOrDefault(); return(row); } return(row); }
public JsonResult ForexSave(BulkPurchaseForex model, string action) { try { if (ModelState.IsValid) { System.Diagnostics.Debug.WriteLine("Forex Save Invoked!!!"); return(Json(Functions.OutPutResponse(true, "Record saved successfully", _forexmodel.Save(model, action)))); } return(Json(Functions.OutPutResponse(false, "Record saved failed", ModelState))); } catch (Exception ex) { return(Json(Functions.OutPutResponse(false, ex.Message))); } }