private static void UpdateMemberInfoDetails(PublicMemberInfo publicMemberInfo, MemberInfo memberInfo) { if (!string.IsNullOrEmpty(publicMemberInfo.Name)) { memberInfo.Name = publicMemberInfo.Name.Trim(); } if (!string.IsNullOrEmpty(publicMemberInfo.ContactNo)) { memberInfo.ContactNo = publicMemberInfo.ContactNo.Trim(); } memberInfo.DateOfInitiation = publicMemberInfo.DateOfInitiation; memberInfo.DateOfBirth = publicMemberInfo.DateOfBirth; if (!string.IsNullOrEmpty(publicMemberInfo.CountryOfBirth)) { memberInfo.CountryOfBirth = publicMemberInfo.CountryOfBirth; } memberInfo.GenderID = publicMemberInfo.GenderID; if (!string.IsNullOrEmpty(publicMemberInfo.IDCardNo)) { memberInfo.IDCardNo = publicMemberInfo.IDCardNo; } memberInfo.InitiateTypeID = publicMemberInfo.InitiateTypeID; if (publicMemberInfo.MemberFeeExpiredDate.HasValue) { memberInfo.MemberFeeExpiredDate = publicMemberInfo.MemberFeeExpiredDate; } if (publicMemberInfo.MemberNo.HasValue) { memberInfo.MemberNo = publicMemberInfo.MemberNo; } memberInfo.PassportNo = publicMemberInfo.PassportNo; memberInfo.Remark = publicMemberInfo.Remark; }
private MemberInfo GetMemberInfo(PublicMemberInfo publicMemberInfo, Guid memberID) { MemberInfo memberInfo = new MemberInfo(); memberInfo.IsActive = true; memberInfo.MemberID = memberID; UpdateMemberInfoDetails(publicMemberInfo, memberInfo); //memberInfo.InitiateTypeID = publicMemberInfo.InitiateTypeID; //memberInfo.Name = publicMemberInfo.Name.Trim(); //if (!string.IsNullOrEmpty(publicMemberInfo.ContactNo)) //{ // memberInfo.ContactNo = publicMemberInfo.ContactNo.Trim(); //} //memberInfo.DateOfInitiation = publicMemberInfo.DateOfInitiation; //memberInfo.DateOfBirth = publicMemberInfo.DateOfBirth; //memberInfo.CountryOfBirth = publicMemberInfo.CountryOfBirth; //memberInfo.GenderID = publicMemberInfo.GenderID; //if (!string.IsNullOrEmpty(publicMemberInfo.IDCardNo)) //{ // memberInfo.IDCardNo = publicMemberInfo.IDCardNo.Trim(); //} //if (publicMemberInfo.MemberFeeExpiredDate.HasValue) //{ // memberInfo.MemberFeeExpiredDate = publicMemberInfo.MemberFeeExpiredDate; //} //if (publicMemberInfo.MemberNo.HasValue) //{ // memberInfo.MemberNo = publicMemberInfo.MemberNo; //} //memberInfo.PassportNo = publicMemberInfo.PassportNo; //memberInfo.Remark = publicMemberInfo.Remark; return(memberInfo); }
private PublicMemberInfo GetPublicMemberInfo(Guid?id, string userName, string email) { PublicMemberInfo publicMemberInfo = new PublicMemberInfo(); MemberInfo memberInfo = _entities.MemberInfos.Single(a => a.MemberID == id); publicMemberInfo.ContactNo = memberInfo.ContactNo; publicMemberInfo.DateOfInitiation = memberInfo.DateOfInitiation; publicMemberInfo.Email = email; publicMemberInfo.GenderID = memberInfo.GenderID; publicMemberInfo.Gender = memberInfo.Gender.Name; publicMemberInfo.ID = memberInfo.MemberID; publicMemberInfo.MemberNo = memberInfo.MemberNo; publicMemberInfo.Name = memberInfo.Name; publicMemberInfo.UserName = userName; publicMemberInfo.MemberFeeExpiredDate = memberInfo.MemberFeeExpiredDate; publicMemberInfo.IsActive = memberInfo.IsActive; publicMemberInfo.IDCardNo = memberInfo.IDCardNo; publicMemberInfo.DateOfBirth = memberInfo.DateOfBirth; publicMemberInfo.CountryOfBirth = memberInfo.CountryOfBirth; publicMemberInfo.InitiateTypeID = memberInfo.InitiateTypeID; publicMemberInfo.InitiateType = memberInfo.InitiateType.Name; publicMemberInfo.PassportNo = memberInfo.PassportNo; publicMemberInfo.Remark = memberInfo.Remark; return(publicMemberInfo); }
private void UpdateMemberInfo(PublicMemberInfo publicMemberInfo, MemberInfo memberInfo) { if (Roles.IsUserInRole("Administrator")) { memberInfo.IsActive = publicMemberInfo.IsActive; } UpdateMemberInfoDetails(publicMemberInfo, memberInfo); }
public ActionResult Edit(Guid id, PublicMemberInfo PublicMemberInfo, FormCollection collection) { MemberInfo memberInfo = _entities.MemberInfos.SingleOrDefault(a => a.MemberID == id); try { UpdateMemberInfo(PublicMemberInfo, memberInfo); //if (IsFromLocalHost()) //{ // SMCHDBLocalEntities _localEntities = new SMCHDBLocalEntities(); // OrdinaryMemberInfo ordinaryMemberInfo = _localEntities.OrdinaryMemberInfos.Single(a => a.IMemberID == id); // UpdateModel(ordinaryMemberInfo, "OrdinaryMemberInfo"); // if (ordinaryMemberInfo.MemberFeePayByID == 1) // { // memberInfo.MemberFeeExpiredDate = new DateTime(2020, 12, 31); // } // //_entities.SaveChanges(); // SetBackToNull(ordinaryMemberInfo); // _localEntities.SaveChanges(); //} _entities.SaveChanges(); AccountController ac = new AccountController(); ac.UpdateEmail(PublicMemberInfo.Email, id); if (Roles.IsUserInRole("Administrator")) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Details", new { id = id })); } } catch { return(View()); } }
public ActionResult Details(Guid?id) { MembershipUser user = Membership.GetUser(); if (id == null) { id = ((Guid)(user.ProviderUserKey)); } else { user = Membership.GetUser(id); } PublicMemberInfo publicMemberInfo = GetPublicMemberInfo(id, user.UserName, user.Email); var viewModel = new OrdinaryMemberViewModel { PublicMemberInfo = publicMemberInfo, }; if (IsFromLocalHost()) { SMCHDBLocalEntities _localEntities = new SMCHDBLocalEntities(); if (_localEntities.OrdinaryMemberInfos.Any(a => a.IMemberID == id)) { OrdinaryMemberInfo ordinaryMemberInfo = _localEntities.OrdinaryMemberInfos.Single(a => a.IMemberID == id); viewModel.OrdinaryMemberInfo = ordinaryMemberInfo; //var viewModel = new OrdinaryMemberViewModel //{ // OrdinaryMemberInfo = ordinaryMemberInfo, // PublicMemberInfo = publicMemberInfo, //}; if (ordinaryMemberInfo.MemberFeePayByID.HasValue) { ViewData["PayMethodName"] = _entities.PayMethods.SingleOrDefault(a => a.ID == ordinaryMemberInfo.MemberFeePayByID).Name; } } } ViewData["IsFromLocalHost"] = IsFromLocalHost(); return(View(viewModel)); }
public override void Parse(PublicMemberInfo memberInfo) { object obj = null; switch (m_jsonData.GetJsonType()) { case JsonType.None: break; case JsonType.Object: obj = JsonMapper.ToObject(JsonMapper.ToJson(m_jsonData), memberInfo.type); break; case JsonType.Array: // obj = JsonMapper.ToObject(JsonMapper.ToJson(memberData), memberInfo.type) break; case JsonType.String: obj = Convert.ChangeType((string)m_jsonData, memberInfo.type); break; case JsonType.Int: obj = Convert.ChangeType((int)m_jsonData, memberInfo.type); break; case JsonType.Long: obj = Convert.ChangeType((long)m_jsonData, memberInfo.type); break; case JsonType.Double: obj = Convert.ChangeType((double)m_jsonData, memberInfo.type); break; case JsonType.Boolean: obj = Convert.ChangeType((bool)m_jsonData, memberInfo.type); break; } Value = obj; }
public ActionResult Edit(Guid id) { MembershipUser user = Membership.GetUser(id); PublicMemberInfo publicMemberInfo = GetPublicMemberInfo(id, user.UserName, user.Email); var viewModel = new OrdinaryMemberViewModel { PublicMemberInfo = publicMemberInfo, Gender = _entities.Genders.ToList(), PayMethod = _entities.PayMethods.ToList(), InitiateType = _entities.InitiateTypes.Where(a => a.ID <= 2).ToList(), }; //if (IsFromLocalHost()) //{ // SMCHDBLocalEntities _localEntities = new SMCHDBLocalEntities(); // viewModel = new OrdinaryMemberViewModel // { // OrdinaryMemberInfo = _localEntities.OrdinaryMemberInfos.Single(a => a.IMemberID == id), // PublicMemberInfo = publicMemberInfo, // Nationality = _localEntities.Nationalities.ToList(), // Gender = _entities.Genders.ToList(), // Race = _localEntities.Races.ToList(), // EmploymentStatus = _localEntities.EmploymentStatuses.ToList(), // PayMethod = _entities.PayMethods.ToList(), // InitiateType = _entities.InitiateTypes.Where(a => a.ID <= 2).ToList(), // }; // DefaultSettings(viewModel); //} ViewData["IsFromLocalHost"] = IsFromLocalHost(); return(View(viewModel)); }
public void updateMemberFeeExipredDate(List <PublicMemberInfo> memberInfos) { var latestMemberFeePayments = (from r in _entities.MemberFeePayments orderby r.ToDate descending group r by r.MemberInfo.MemberNo into h select new { MemberNo = h.Key, ToDate = h.Max(a => a.ToDate), }).ToList(); foreach (var mfp in latestMemberFeePayments) { if (mfp.MemberNo.HasValue && memberInfos.Any(a => a.MemberNo == mfp.MemberNo)) { PublicMemberInfo publicMemberInfo = memberInfos.SingleOrDefault(a => a.MemberNo == mfp.MemberNo); if (mfp.ToDate > publicMemberInfo.MemberFeeExpiredDate) { publicMemberInfo.MemberFeeExpiredDate = mfp.ToDate; } } } }
public ActionResult Create(OrdinaryMemberInfo OrdinaryMemberInfo, PublicMemberInfo PublicMemberInfo, FormCollection collection) { //SMCHDBLocalEntities _localEntities = new SMCHDBLocalEntities(); AccountController ac = new AccountController(); ac.InitializePublic(HttpContext.Request.RequestContext); try { Guid memberID = Guid.Empty; string errorString = ac.RegisterOrdinaryMember(PublicMemberInfo.Name, PublicMemberInfo.Email, ref memberID); if (!string.IsNullOrEmpty(errorString)) { ViewData["errorMsg"] = errorString; throw new Exception(); } if (OrdinaryMemberInfo.MemberFeePayByID == 1) { PublicMemberInfo.MemberFeeExpiredDate = new DateTime(2020, 12, 31); } MemberInfo memberInfo = GetMemberInfo(PublicMemberInfo, memberID); _entities.AddToMemberInfos(memberInfo); _entities.SaveChanges(); SetBackToNull(OrdinaryMemberInfo); //OrdinaryMemberInfo.IMemberID = memberID; //_localEntities.AddToOrdinaryMemberInfos(OrdinaryMemberInfo); //_localEntities.SaveChanges(); MembershipUser newUser = Membership.GetUser(memberInfo.MemberID); if (newUser.Email.Trim() != "*****@*****.**") { HomeController hc = new HomeController(); try { hc.sendUserEmail(newUser); } catch { } } return(RedirectToAction("Index")); } catch { //Invalid - redisplay with errors var viewModel = new OrdinaryMemberViewModel { OrdinaryMemberInfo = OrdinaryMemberInfo, PublicMemberInfo = PublicMemberInfo, //Nationality = _localEntities.Nationalities.ToList(), Gender = _entities.Genders.ToList(), //Race = _localEntities.Races.ToList(), //EmploymentStatus = _localEntities.EmploymentStatuses.ToList(), PayMethod = _entities.PayMethods.ToList(), InitiateType = _entities.InitiateTypes.Where(a => a.ID <= 2).ToList(), }; DefaultSettings(viewModel); return(View(viewModel)); } }