public ActionResult UpdateDeposit(FormCollection form, HttpPostedFileBase DepositUpdateImage) { Deposit Deposit_Details = JsonConvert.DeserializeObject <Deposit>(form["Deposit_details"]); Deposit Deposit_Db = db.Deposit.Where(s => s.DepositID == Deposit_Details.DepositID).FirstOrDefault(); try { AddGivenImageInCurrentRow(ref Deposit_Db, Deposit_Details, "DescriptionFile", DepositUpdateImage, form["DescriptionFilePath"]); if (Deposit_Db.DepositID > 0) { SetClientDepositToDatabaseDB(ref Deposit_Db, Deposit_Details); db.Entry(Deposit_Db).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); AccountingHistory accountingHistory = db.AccountingHistory.Where(x => x.DepositID == Deposit_Db.DepositID).FirstOrDefault(); //Mode 1 mean Create 2 mean Update SetInformationForAccountHistory(ref accountingHistory, Deposit_Db, 2); db.AccountingHistory.Add(accountingHistory); db.SaveChanges(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteDeposit(int ID) { try { var deposit = db.Deposit.Where(s => s.DepositID == ID).FirstOrDefault(); deposit.DeleteBy = AppUtils.GetLoginUserID(); deposit.DeleteDate = AppUtils.GetDateTimeNow(); deposit.Status = AppUtils.TableStatusIsDelete; db.Entry(deposit).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); AccountingHistory accountingHistory = db.AccountingHistory.Where(x => x.DepositID == deposit.DepositID).FirstOrDefault(); accountingHistory.Status = AppUtils.TableStatusIsDelete; db.SaveChanges(); var JSON = Json(new { success = true }, JsonRequestBehavior.AllowGet); JSON.MaxJsonLength = int.MaxValue; return(JSON); } catch (Exception ex) { var JSON = Json(new { success = false }, JsonRequestBehavior.AllowGet); JSON.MaxJsonLength = int.MaxValue; return(JSON); } }
public ActionResult InsertNewDeposit(FormCollection form, HttpPostedFileBase DescriptionImage) { Deposit DepositInfo = JsonConvert.DeserializeObject <Deposit>(form["NewDepositInformation"]); Deposit DepositReturn = new Deposit(); try { DepositInfo.Status = AppUtils.TableStatusIsActive; DepositInfo.CreateBy = AppUtils.GetLoginUserID(); DepositInfo.CreateDate = AppUtils.GetDateTimeNow(); DepositReturn = db.Deposit.Add(DepositInfo); db.SaveChanges(); if (DescriptionImage != null) { SaveImageInFolderAndAddInformationInVendorTable(ref DepositInfo, "Description", DescriptionImage); } if (DepositReturn.DepositID > 0) { db.SaveChanges(); AccountingHistory accountingHistory = new AccountingHistory(); //Mode 1 mean Create 2 mean Update SetInformationForAccountHistory(ref accountingHistory, DepositReturn, 1); db.AccountingHistory.Add(accountingHistory); db.SaveChanges(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }