public bool InsertPayment(_Payment pay) { string sql = "sp_payment_INSERT"; object[] obj = { "@SlpID", pay.SlpID, "@BnkAccNumber", pay.BnkAccNumber, "@PayDate", pay.PayDate.ToString("yyyy-MM-dd HH:mm:ss"), "@PayPrice", pay.PayPrice, "@PayImg", pay.PayImg }; using (TransactionScope ts = new TransactionScope()) { try { Db.Insert(sql, obj); ts.Complete(); return(true); } catch { return(false); } } }
public ActionResult PayMent(_Payment data) { HttpPostedFileBase file = data.Photo; var Memid = Session["MemID"].ToString(); var checkMemid = db.SELLPRODUCT.Where(c => c.MemID == Memid && c.SlpID == data.SlpID).Count(); if (checkMemid > 0) { try { string path = ""; path = System.IO.Path.Combine(Server.MapPath("/Photos/PayMent/" + Memid)); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var filepath = Path.Combine(path, System.IO.Path.GetFileName(file.FileName).Trim()); file.SaveAs(filepath); //save photo to server var file_db = System.IO.Path.Combine("/Photos/PayMent/" + Memid, Path.GetFileName(file.FileName)); file_db = file_db.Replace('\\', '/'); data.PayImg = file_db; if (_payRepository.InsertPayment(data)) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } catch { // ModelState.AddModelError("", "Please complete the following information for Images!"); }; } else { return(RedirectToAction("Error404", "Shipping")); } return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); }