コード例 #1
0
ファイル: AccountController.cs プロジェクト: kirti-zare/EOS
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                // ChangePassword will throw an exception rather
                // than return false in certain failure scenarios.
                bool changePasswordSucceeded;
                try
                {
                    var merkezDc = new ESSMerkezDataContext(Globals.MerkezConnectionString);

                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
                    if (changePasswordSucceeded)
                    {
                        var user = merkezDc.Users.First(x => x.IdentityNo == User.Identity.Name);
                        user.UserPassword = model.NewPassword;
                        merkezDc.SubmitChanges();
                        ViewData["Message"] = "Şifreniz başarı ile güncellendi.";
                    }
                    else
                    {
                        ViewData["Message"] = "Şifreler uyuşmuyor.";
                        ModelState.AddModelError("", "Şifreler uyuşmuyor.");
                    }

                }
                catch (Exception)
                {
                    ViewData["Message"] = "Bir hata oluştu!";
                    return View();
                }
            }

            return View(model);
        }
コード例 #2
0
ファイル: CandidateController.cs プロジェクト: kirti-zare/EOS
        public JsonResult Orders(int electionId, int partyId, int regionId)
        {
            m_internetDc = new EOSInternetDataContext(Globals.InternetConnectionString);
            string result = "";
            ESSMerkezDataContext merkezDc = new ESSMerkezDataContext(Globals.MerkezConnectionString);
            if (partyId != 0 && electionId != 0 && regionId != 0)
            {
                if (m_internetDc.Parties.Any(p => p.PartyId == partyId)
                    && merkezDc.Elections.Any(e => e.ElectionId == electionId)
                    && merkezDc.Regions.Any(r => r.RegionId == regionId)
                    )
                {
                    int count = merkezDc.Regions.First(r => r.RegionId == regionId).CandidateCount.Value;
                    var candidates = m_internetDc.Candidates.Where(c => c.PartyId == partyId && c.RegionId == regionId && c.ElectionId == electionId).ToList();
                    List<int> exist = new List<int>();
                    List<int> usable = new List<int>();
                    foreach (var candidate in candidates)
                    {
                        exist.Add(candidate.OrderNo.Value);
                    }

                    for (int i = 1; i <= count; i++)
                    {
                        if (!exist.Contains(i))
                        {
                            usable.Add(i);
                            result += "<option value='" + i + "'>" + i + " . Sıra</option>\n";
                        }
                    }
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
            }

            return Json(result, JsonRequestBehavior.AllowGet);
        }