public ActionResult PayMoMo(int?id) { var coo = new FunctionsController(); var idus = coo.CookieID(); Pakage pakage = db.Pakages.Find(id); var money = pakage.pakage_coin * 1000; //request params need to request to MoMo system string endpoint = "https://test-payment.momo.vn/gw_payment/transactionProcessor"; string partnerCode = "MOMO5RGX20191128"; string accessKey = "M8brj9K6E22vXoDB"; string serectkey = "nqQiVSgDMy809JoPF6OzP5OdBUB550Y4"; string orderInfo = "Nạp " + pakage.pakage_coin + " vào tài khoản " + idus.user_email; string returnUrl = "https://localhost:44327/Pays/ReturnUrl"; string notifyurl = "https://localhost:44327/Pays/ReturnUrl"; string amount = money.ToString(); string orderid = Guid.NewGuid().ToString(); string requestId = Guid.NewGuid().ToString(); string extraData = ""; //Before sign HMAC SHA256 signature string rawHash = "partnerCode=" + partnerCode + "&accessKey=" + accessKey + "&requestId=" + requestId + "&amount=" + amount + "&orderId=" + orderid + "&orderInfo=" + orderInfo + "&returnUrl=" + returnUrl + "¬ifyUrl=" + notifyurl + "&extraData=" + extraData; MoMoSecurity crypto = new MoMoSecurity(); string signature = crypto.signSHA256(rawHash, serectkey); //build body json request JObject message = new JObject { { "partnerCode", partnerCode }, { "accessKey", accessKey }, { "requestId", requestId }, { "amount", amount }, { "orderId", orderid }, { "orderInfo", orderInfo }, { "returnUrl", returnUrl }, { "notifyUrl", notifyurl }, { "extraData", extraData }, { "requestType", "captureMoMoWallet" }, { "signature", signature } }; string responseFromMomo = PaymentRequest.sendPaymentRequest(endpoint, message.ToString()); JObject jmessage = JObject.Parse(responseFromMomo); Session["idpake"] = id; return(Redirect(jmessage.GetValue("payUrl").ToString())); }
private void CreatePakage_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (!Editing) { Pakage p = new Pakage() { Name = NameBox.Text, DownloadURL = URLBox.Text, Description = DescriptionBox.Text.Replace("{n}", Environment.NewLine), JName = JNameBox.Text, exe = EXEBox.Text, args = ArgsBox.Text, User = UserBox.Text, Password = PassBox.Password }; Corelib.Pakages.Add(p); } else { Corelib.Current.Name = NameBox.Text; Corelib.Current.DownloadURL = URLBox.Text; Corelib.Current.Description = DescriptionBox.Text.Replace("{n}", Environment.NewLine); Corelib.Current.JName = JNameBox.Text; Corelib.Current.exe = EXEBox.Text; Corelib.Current.args = ArgsBox.Text; Corelib.Current.User = UserBox.Text; Corelib.Current.User = UserBox.Text; Corelib.Current.Password = PassBox.Password; } Corelib.ExportList(); }
private void ExportBtn_Click(object sender, EventArgs e) { Pakage p = new Pakage(); p.Name = textBoxName.Text; p.Description = textBoxDescription.Text; p.Description = p.Description.Replace("{n}", Environment.NewLine); p.DownloadURL = textBoxURL.Text; p.exe = textBoxExe.Text; p.JName = textBoxJName.Text; p.args = textBoxArgs.Text; p.Password = textBoxPassword.Text; p.User = textBoxUser.Text; Program.Pakages.Add(p); Corelib lib = new Corelib(); lib.ExportList(Program.Pakages); Program.Import(); Close(); }
// Khôi phục public JsonResult Restore(int?id) { Pakage pakage = db.Pakages.Find(id); if (pakage.pakage_active == 1) { pakage.pakage_active = 2; } else { pakage.pakage_active = 1; } db.SaveChanges(); var list = from item in db.Pakages where item.pakage_active == 2 select new { id = (int)item.pakege_id, coin = (int)item.pakage_coin, money = item.pakage_money.ToString(), active = (int)item.pakage_active }; return(Json(list, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteConfirmed(int id) { Pakage pakage = db.Pakages.Find(id); db.Pakages.Remove(pakage); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "pakege_id,pakage_coin,pakage_money,pakage_active")] Pakage pakage) { pakage.pakage_active = 1; db.Pakages.Add(pakage); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "pakage_id,pakage_name,pakage_note,pakage_money,pakage_precent,pakage_active,role_id")] Pakage pakage) { if (ModelState.IsValid) { db.Entry(pakage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.role_id = new SelectList(db.Roles, "role_id", "role_name", pakage.role_id); return(View(pakage)); }
// GET: Admin/PakagesAdmin/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pakage pakage = db.Pakages.Find(id); if (pakage == null) { return(HttpNotFound()); } return(View(pakage)); }
public ActionResult Edit([Bind(Include = "pakege_id,pakage_coin,pakage_money,pakage_active")] Pakage pakage) { var coin = pakage.pakage_coin * 1000; if (ModelState.IsValid) { db.Entry(pakage).State = EntityState.Modified; pakage.pakage_money = coin.Value.ToString("#,##0") + " VNĐ"; pakage.pakage_active = 1; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pakage)); }
// Hàm sửa public bool Edit(Pakage pakage) { try { db.Entry(pakage).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
// Hàm restore public bool Restore(int?id) { try { Pakage pakage = db.Pakages.Find(id); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
// GET: Admin/PakagesAdmin/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pakage pakage = db.Pakages.Find(id); if (pakage == null) { return(HttpNotFound()); } ViewBag.role_id = new SelectList(db.Roles, "role_id", "role_name", pakage.role_id); return(View(pakage)); }
public bool Create(Pakage pakage) { try { //Mac dinh db.Pakages.Add(pakage); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public int DeletePakage(int id) { int check = 0; try { Pakage pakage = obj.Pakages.First(x => x.Id.Equals(id)); pakage.Status = 0; obj.SubmitChanges(); check = 1; List <PakageService> ps = obj.PakageServices.Where(x => x.PakagesId.Equals(id)).ToList(); obj.PakageServices.DeleteAllOnSubmit(ps); obj.SubmitChanges(); } catch (Exception e) { } return(check); }
public int PostPakage(PakagesClass PC) { int check = 0; try { Pakage pakage = new Pakage(); pakage.Name = PC.Name; pakage.PakageType = PC.PakageType; pakage.CostPerMonth = PC.CostPerMonth; pakage.ServicesIncluded = PC.ServicesIncluded; pakage.Status = 1; pakage.AddDate = DateTime.Now.ToShortDateString(); obj.Pakages.InsertOnSubmit(pakage); obj.SubmitChanges(); check = pakage.Id; } catch (Exception e) { check = 0; } return(check); }
public async Task Download(Pakage p) { if (!p.IsInstalled) { InUse = true; Corelib Lib = new Corelib(); Program.Downloading = p; using (WebClient wc = new WebClient()) { wc.Credentials = new NetworkCredential(Program.Downloading.User, Program.Downloading.Password); wc.DownloadProgressChanged += wc_DownloadProgressChanged; wc.DownloadFileCompleted += wc_DownloadFinished; await Task.Run(() => wc.DownloadFileAsync ( new System.Uri(Program.Downloading.DownloadURL), Lib.path + Program.Downloading.JName + ".zip" )); } } }
// GET: Admin/PakagesAdmin/Edit/5 public ActionResult Edit(int?id) { HttpCookie cookie = Request.Cookies["admin_id"]; if (cookie != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pakage pakage = db.Pakages.Find(id); if (pakage == null) { return(HttpNotFound()); } return(View(pakage)); } else { return(RedirectToAction("Login", "UsersAdmin")); } }
public int UpdatePakage(PakagesClass PC) { int check = 0; try { Pakage pakage = obj.Pakages.First(x => x.Id.Equals(PC.Id)); pakage.Name = PC.Name; pakage.PakageType = PC.PakageType; pakage.CostPerMonth = PC.CostPerMonth; pakage.ServicesIncluded = PC.ServicesIncluded; pakage.Status = 1; pakage.AddDate = DateTime.Now.ToShortDateString(); obj.SubmitChanges(); check = pakage.Id; List <PakageService> ps = obj.PakageServices.Where(x => x.PakagesId.Equals(pakage.Id)).ToList(); obj.PakageServices.DeleteAllOnSubmit(ps); obj.SubmitChanges(); } catch (Exception e) { check = 0; } return(check); }
public ActionResult ReturnUrl(int errorCode, int amount, string orderId) { var coo = new FunctionController(); var id = coo.CookieID(); if (Session["pakeid"] == null) { return(RedirectToAction("HistoryPay")); } else { var pake = Int32.Parse(Session["pakeid"].ToString()); Pakage pakage = db.Pakages.Find(pake); User us = db.Users.Find(id.user_id); if (us.version_id == 2) { return(Redirect("/Pays/IndexPakage")); } else { if (errorCode.Equals(0)) { ViewBag.Note = "Thanh toán thành công"; us.version_id = 2; us.candidate_amoutcv = 10; us.user_deadline = DateTime.Now.AddYears(1); db.SaveChanges(); Bill bill = new Bill { user_id = id.user_id, bill_active = true, bill_datecreate = DateTime.Now, bill_dealine = DateTime.Now.AddYears(1), bill_sum = amount, pakege_id = pakage.pakage_id, bill_key = Guid.NewGuid().ToString(), bill_orderid = orderId }; db.Bills.Add(bill); db.SaveChanges(); Session["pakeid"] = null; return(RedirectToAction("HistoryPay")); } else { ViewBag.Note = "Thanh toán thất bại"; Bill bill = new Bill { user_id = id.user_id, bill_active = false, bill_datecreate = DateTime.Now, bill_dealine = DateTime.Now, bill_sum = amount, pakege_id = pakage.pakage_id, bill_key = Guid.NewGuid().ToString(), bill_orderid = orderId }; db.Bills.Add(bill); db.SaveChanges(); Session["pakeid"] = null; return(RedirectToAction("HistoryPay")); } } } }
public ActionResult ReturnUrl(int errorCode) { if (Session["idpake"] == null) { return(RedirectToAction("History")); } else { var coo = new FunctionsController(); var id = coo.CookieID(); User user = db.Users.Find(id.user_id); int idpake = int.Parse(Session["idpake"].ToString()); Pakage pakage = db.Pakages.Find(idpake); if (errorCode.Equals(0)) { user.user_coin = user.user_coin + pakage.pakage_coin; db.SaveChanges(); Bill bills = new Bill { bill_datecreate = DateTime.Now, bill_active = true, user_id = id.user_id, pakege_id = pakage.pakege_id, bill_dealine = DateTime.Now, coin = pakage.pakage_coin }; db.Bills.Add(bills); History history = new History() { user_id = id.user_id, his_datecreate = DateTime.Now, his_content = id.user_name + " đã nạp thành công " + pakage.pakage_coin + " xu vào tài khoản" }; db.Historys.Add(history); db.SaveChanges(); Session["idpake"] = null; return(RedirectToAction("History")); } else { Bill bills = new Bill { bill_datecreate = DateTime.Now, bill_active = false, user_id = id.user_id, pakege_id = pakage.pakege_id, bill_dealine = DateTime.Now.AddDays(10), coin = pakage.pakage_coin }; db.Bills.Add(bills); db.SaveChanges(); Session["idpake"] = null; return(RedirectToAction("History")); } } }
public ActionResult ReturnUrl(int errorCode, int amount) { if (Session["pakeid"] == null) { return(RedirectToAction("HistoryPay")); } else { var coo = new FunctionController(); var idus = coo.CookieIDEm(); User us = db.Users.Find(idus.user_id); int pake = Int32.Parse(Session["pakeid"].ToString()); Pakage pakege = db.Pakages.Find(pake); if (errorCode.Equals(0)) { ViewBag.Note = "Thanh toán thành công"; if (pakege.pakage_id == 11) { us.employer_amoutjob = 30; us.version_id = Common.Common.VER_EM_CC1; us.user_deadline = DateTime.Now.AddMonths(1); } else if (pakege.pakage_id == 12) { us.employer_amoutjob = 50; us.version_id = Common.Common.VER_EM_CC2; us.user_deadline = DateTime.Now.AddMonths(1); } else if (pakege.pakage_id == 13) { us.employer_amoutjob = 80; us.version_id = Common.Common.VER_EM_PRO; us.user_deadline = DateTime.Now.AddMonths(1); } else if (pakege.pakage_id == 14) { us.employer_amoutjob = 120; us.version_id = Common.Common.VER_EM_MAX; us.user_deadline = DateTime.Now.AddMonths(1); } else { us.user_active = false; } Bill bill = new Bill { bill_active = true, bill_datecreate = DateTime.Now, bill_dealine = DateTime.Now.AddMonths(1), bill_sum = amount, user_id = us.user_id, pakege_id = pake }; db.Bills.Add(bill); db.SaveChanges(); Session["pakeid"] = null; return(RedirectToAction("HistoryPay")); } else { ViewBag.Note = "Thanh toán thất bại"; Bill bill = new Bill { bill_active = false, bill_datecreate = DateTime.Now, bill_dealine = DateTime.Now, bill_sum = amount, user_id = us.user_id, pakege_id = pake }; db.Bills.Add(bill); db.SaveChanges(); Session["pakeid"] = null; return(RedirectToAction("HistoryPay")); } } }