private static void SetBackToNull(OrdinaryMemberInfo ordinaryMemberInfo) { if (ordinaryMemberInfo.MemberFeePayByID == 0) { ordinaryMemberInfo.MemberFeePayByID = null; } if (ordinaryMemberInfo.NationalityID == 0) { ordinaryMemberInfo.NationalityID = null; } if (ordinaryMemberInfo.RaceID == 0) { ordinaryMemberInfo.RaceID = null; } if (ordinaryMemberInfo.EmploymentStatusID == 0) { ordinaryMemberInfo.EmploymentStatusID = null; } }
private static void ConvertZeroToNull(OrdinaryMemberInfo ordinaryMemberInfo) { if (!ordinaryMemberInfo.NationalityID.HasValue && ordinaryMemberInfo.NationalityID.Value == 0) { ordinaryMemberInfo.NationalityID = null; } if (!ordinaryMemberInfo.RaceID.HasValue && ordinaryMemberInfo.RaceID.Value == 0) { ordinaryMemberInfo.RaceID = null; } if (!ordinaryMemberInfo.EmploymentStatusID.HasValue && ordinaryMemberInfo.EmploymentStatusID.Value == 0) { ordinaryMemberInfo.EmploymentStatusID = null; } if (!ordinaryMemberInfo.MemberFeePayByID.HasValue && ordinaryMemberInfo.MemberFeePayByID.Value == 0) { ordinaryMemberInfo.MemberFeePayByID = null; } }
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 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)); } }