public ActionResult Create(PointModel.PointModelShow item, string phone) { s26webDataContext db = new s26webDataContext(); List<string> mobile_list = new List<string>(); mobile_list = phone.Split(',').ToList(); int user_id = Method.Get_UserId_Admin(Request.Cookies, Session); item.UId = user_id; item.Category = 2; item.Result = true; foreach (var i in mobile_list) { item.Mobile = i; if (data.Insert(item) <= 0) { TempData["err"] = ""; return RedirectToAction("Index"); } } return RedirectToAction("Index"); }
public static List<Export> Get_Export(PointModel datas) { /*-------------------匯出宣告-------------------*/ s26webDataContext db = new s26webDataContext(); Export export = new Export(); List<Export> exp = new List<Export>(); List<string> bir = new List<string> { "", "", "" }; var newdata = datas.Get().OrderByDescending(o => o.Id); /*-------------------匯出宣告End-------------------*/ foreach (var d in newdata) { export.Id = d.Id.ToString(); export.Name = d.Name; export.Mobile = d.Mobile; export.Category_Name = d.Category_Name; export.Point = d.Point.ToString(); export.Result = d.Result.ToString(); export.FailReason = d.FailReason; export.UserName = d.UserName; export.SendTime = d.SendTime.ToString("yyyy/MM/dd HH:mm"); exp.Add(export); export = new Export(); } db.Connection.Close(); return exp; }
public ActionResult GetPoint(PointModel.PointModelShow item) { item.Vid = Method.Get_UserId(Request.Cookies, Session); item.Mobile = Method.Get_Account(Request.Cookies, Session); item.Category = 33; item.Point = 100; item.Result = true; item.UId = 0; data.Insert(item); return View(); }
public int Insert(PointModel.PointModelShow item) { s26webDataContext db = new s26webDataContext(); try { Point new_item = new Point { VId = db.Volunteers.FirstOrDefault(f => f.Mobile == item.Mobile).Id, Category = item.Category, CategoryReason = item.CategoryReason, Point1 = item.Point, Result = item.Result, FailReason = item.FailReason, UId = item.UId, SendTime = DateTime.UtcNow }; db.Point.InsertOnSubmit(new_item); db.SubmitChanges(); var vol = db.Volunteers.FirstOrDefault(f => f.Mobile == item.Mobile); if (vol != null) { if (vol.Point == null) vol.Point = 0; vol.Point += item.Point; db.SubmitChanges(); } db.Connection.Close(); return new_item.Id; } catch { return -1; } }