public BulkPurchasePayment Save(BulkPurchasePayment model, string action) { ActionMode mode = (ActionMode)Enum.Parse(typeof(ActionMode), action, true); switch (mode) { case ActionMode.Add: BulkPurchasePaymentViewModel.Current.AddItem(model); return(model); case ActionMode.Edit: var payment = BulkPurchasePaymentViewModel.Current; payment.Remove(payment.Where(i => i.Id == model.Id).FirstOrDefault()); payment.AddItem(model); BulkPurchasePaymentViewModel.Current = payment; return(model); case ActionMode.Delete: var removepayment = BulkPurchasePaymentViewModel.Current; removepayment.Remove(removepayment.Where(i => i.Id == model.Id).FirstOrDefault()); BulkPurchasePaymentViewModel.Current = removepayment; return(model); //case ActionMode.Cancel: // break; default: break; } return(null); }
private BulkPurchasePayment FindById(int?id = 0) { BulkPurchasePayment row = new BulkPurchasePayment(); if (id > 0) { var payment = BulkPurchasePaymentViewModel.Current; row = payment.Where(f => f.Id == id).Select(f => f).FirstOrDefault(); return(row); } return(row); }
public JsonResult PaymentSave(BulkPurchasePayment model, string action) { try { if (ModelState.IsValid) { return(Json(Functions.OutPutResponse(true, "Record saved successfully", _paymentmodel.Save(model, action)))); } return(Json(Functions.OutPutResponse(false, "Record saved failed", ModelState))); } catch (Exception ex) { return(Json(Functions.OutPutResponse(false, ex.Message))); } }