public ActionResult Index() { var cepgpDirectory = new DirectoryInfo(Server.MapPath("~/CEPGP/")); var repository = new FileStandingsRepository(cepgpDirectory); var members = repository.GetMembers(); var memberList = new MemberListDto { LastUpdateDate = JsonConvert.SerializeObject(members.LastUpdateDate), Members = new List <MemberDto>() }; foreach (var member in members) { memberList.Members.Add(new MemberDto { Name = member.Name, EP = member.EP.Value, GP = member.GP.Value, PR = member.CalculatePR().Value }); } return(Json(memberList, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(MemberListDto Member) { try { if (ModelState.IsValid) { string result = MemberListDao.Instance.SaveMember(Member, "add"); if (result != "OK") { ViewBag.Message = result; ModelState.Clear(); } else { //ViewBag.Status = TempData["Dropdown"]; ViewBag.Message = "Successfully !!"; //KRPBL.Component.Common.Form.SetAlertMessage(this,"ไม่พบ User ID ที่ระบุ กรุณาตรวจสอบ"); ModelState.Clear(); } } return(View()); } catch (Exception e) { ViewBag.Message = "Error : " + e.Message; return(View()); } }
/// <summary> /// 【扩展模块】带查询条件的分页查询方法 /// </summary> /// <remarks> /// 例子: /// 这是一个开发示例,目的了解API的开发机制<br/> /// 返回为分页过后的列表集合 /// </remarks> /// <param name="input">GetMemberInput DTO 函数</param> /// <returns>用户UserDto</returns> /// <response code="201">返回value字符串</response> /// <response code="400">如果id为空</response> /// <returns></returns> public async Task <PagedResultDto <MemberListDto> > GetPaged(GetMemberInput input) { var entity = new MemberListDto() { Name = "模块化测试接口" }; var entityListDtos = new List <MemberListDto>(); entityListDtos.Add(entity); return(new PagedResultDto <MemberListDto>(10, entityListDtos)); }
// GET: MemberList/Delete/5 public ActionResult Delete(MemberListDto model) { try { string result = MemberListDao.Instance.SaveMember(model, "del"); if (result == "OK") { ViewBag.Message = "Student Deleted Successfully"; } return(RedirectToAction("Index")); } catch (Exception e) { ViewBag.Message = "Error : " + e.Message.ToString(); return(View()); } }
public ActionResult Edit(MemberListDto model) { try { string result = MemberListDao.Instance.SaveMember(model, "edit"); if (result != "OK") { ViewBag.Message = result; } else { return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }
public string SaveMember(MemberListDto model, string action) { string result = "OK"; try { conn = CreateConnection(); MySqlCommand cmd = new MySqlCommand("PD001_SAVE_MEMBERS", conn); cmd.CommandType = CommandType.StoredProcedure; MySqlParameterCollection param = cmd.Parameters; param.Clear(); AddSQLParam(param, "@id", Util.NVLInt(model.id)); AddSQLParam(param, "@username", Util.NVLString(model.username)); //AddSQLParam(param, "@password", Util.NVLString(model.password)); AddSQLParam(param, "@password", action == "del" ? "" : Util.NVLString(DataCryptography.Encrypt(model.password))); AddSQLParam(param, "@fullname", Util.NVLString(model.fullname)); AddSQLParam(param, "@nickname", Util.NVLString(model.nickname)); AddSQLParam(param, "@member_level", Util.NVLString(model.level)); AddSQLParam(param, "@point", Util.NVLInt(model.point)); AddSQLParam(param, "@email", Util.NVLString(model.email)); AddSQLParam(param, "@homepage", Util.NVLString(model.homepage)); AddSQLParam(param, "@telephone", Util.NVLString(model.telephone)); AddSQLParam(param, "@mobile", Util.NVLString(model.mobile)); AddSQLParam(param, "@certify_case", Util.NVLString(model.certify_case)); AddSQLParam(param, "@certify", Util.NVLString(model.certify)); AddSQLParam(param, "@address", Util.NVLString(model.address)); AddSQLParam(param, "@address1", Util.NVLString(model.address1)); AddSQLParam(param, "@address2", Util.NVLString(model.address2)); AddSQLParam(param, "@address3", Util.NVLString(model.address3)); AddSQLParam(param, "@icon", Util.NVLString(model.icon)); AddSQLParam(param, "@img", Util.NVLString(model.img)); AddSQLParam(param, "@mailling", Util.NVLString(model.mailling)); AddSQLParam(param, "@sms", Util.NVLString(model.sms)); AddSQLParam(param, "@member_open", Util.NVLString(model.open)); AddSQLParam(param, "@signature", Util.NVLString(model.signature)); AddSQLParam(param, "@profile", Util.NVLString(model.profile)); AddSQLParam(param, "@memo", Util.NVLString(model.memo)); AddSQLParam(param, "@adviser", Util.NVLString(model.adviser)); AddSQLParam(param, "@leave_date", Util.NVLString(model.leave_date)); AddSQLParam(param, "@intercept_date", Util.NVLString(model.intercept_date)); AddSQLParam(param, "@txt1", Util.NVLString(model.txt1)); AddSQLParam(param, "@txt2", Util.NVLString(model.txt2)); AddSQLParam(param, "@txt3", Util.NVLString(model.txt3)); AddSQLParam(param, "@txt4", Util.NVLString(model.txt4)); AddSQLParam(param, "@txt5", Util.NVLString(model.txt5)); AddSQLParam(param, "@txt6", Util.NVLString(model.txt6)); AddSQLParam(param, "@txt7", Util.NVLString(model.txt7)); AddSQLParam(param, "@txt8", Util.NVLString(model.txt8)); AddSQLParam(param, "@txt9", Util.NVLString(model.txt9)); AddSQLParam(param, "@txt10", Util.NVLString(model.txt10)); AddSQLParam(param, "@member_id", Util.NVLInt(1)); AddSQLParam(param, "@active", Util.NVLInt(model.active)); AddSQLParam(param, "@status", action); conn.Open(); MySqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { result = read.GetString(0).ToString(); } conn.Close(); } catch (Exception e) { result = e.Message.ToString(); } return(result); }