public JsonResult NewProposal(ChangeModel cModel) { var comments = _changeService.GetCommentbyChangeId(cModel.Id); var commentList = new List <CommentModel>(); foreach (var comment in comments) { var user = _changeService.GetCommentUser(comment.Id); var commentModel = Mapper.Map <CommentModel>(comment); var userModel = Mapper.Map <UserModel>(user); commentModel.User = userModel; commentModel.SeeMore = commentModel.Content.Length > 150 ? true : false; if (commentModel.Content.Length > 150) { commentModel.Content = commentModel.Content.Substring(0, 150); } else { commentModel.Content = commentModel.Content; } commentModel.TotalVotes = comment.TotalVotes; commentList.Add(commentModel); } commentList = commentList.OrderByDescending(x => x.TimeStamp).ToList(); return(Json(commentList)); }
public static bool processChanges(ChangeModel model) { foreach (TeacherChange change in model.Changes) { int id = int.Parse(change.id); int sentence = 0; int helper = id; while (helper > model.RModel.Content[sentence].Length - 1) { helper -= model.RModel.Content[sentence++].Length; } if (change.action.Equals("add")) { model.RModel.Content[sentence][helper].POS = POSType(change.pos); } else { model.RModel.Content[sentence][helper].POS = POSType("Unknown"); } } return(SQLDatabase.addPassage(model.Title, GenerateHTML(model.RModel.Content, true))); }
public void ChangeCalculatorTest(int amount, int pay, ChangeModel expected) { var sut = new ChangeCalculator(); var actual = sut.CalculateChange(amount, pay); actual.Should().BeEquivalentTo(expected); }
/// <summary> /// Raises event 'ChangeModel' /// </summary> protected virtual void OnChangeModel() { if (ChangeModel != null) { ChangeModel.Invoke(this, System.EventArgs.Empty); } }
public ActionResult ChangePass(ChangeModel model) { Account acc = new Account(); if (ModelState.IsValid) { var user = db.Accounts.SingleOrDefault(a => a.Username == model.Username); if (user != null) { if (user.Password == model.Password) //nếu đúng pass của tài khoản mới cập nhập { user.Password = model.NewPassword; //Hàm cập nhập mật khẩu db.SaveChanges(); TempData["Success"] = "Đổi mật khẩu thành công"; return(RedirectToAction("Index", "Account")); } else { ModelState.AddModelError("", "Mật khẩu cũ không dúng, vui lòng nhập lại!"); return(View()); } } } ModelState.AddModelError("", "Đổi mật khẩu thất bại"); return(View()); }
public JsonResult SubmitChange(ChangeModel model) { var change = Mapper.Map <ChangeTable>(model); var userId = User.Identity.GetUserId(); var result = _changeService.SaveChange(change, userId); return(Json(result)); }
private async void OnNewRouteClicked(object sender, EventArgs e) { if (routePoints.Count() == 0) { await DisplayAlert("Błąd", "Dodaj punkt na mapę", "Ok"); return; } if (String.IsNullOrWhiteSpace(trasaEntry.Text)) { await DisplayAlert("Błąd", "Podaj nazwę trasy", "Ok"); return; } if (routePoints.Count() > 11) // dodatkowe zabezpieczenie na przycisk, nie moze byc > 10 bo wyswietla niepotrzebnie błąd { await DisplayAlert("Błąd", "Można do trasy dodać maksymalnie 10 punktów", "Ok"); } List <int> idList = new List <int>(); foreach (Points tmp in routePoints) { var json = JsonConvert.SerializeObject(tmp); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpClient client = new HttpClient(); var result = await client.PostAsync("http://dearjean.ddns.net:44301/api/Points3", content); var pointResult = JsonConvert.DeserializeObject <Points>(result.Content.ReadAsStringAsync().Result); if (result.StatusCode != HttpStatusCode.Created) { await DisplayAlert("Błąd", "Spróbuj ponownie później", "Ok"); Debug.WriteLine(result); return; } idList.Add(pointResult.Id); } var model = new ChangeModel { UpdateList = idList, Name = trasaEntry.Text, Description = opistrasyEntry.Text }; var json2 = JsonConvert.SerializeObject(model); var content2 = new StringContent(json2, Encoding.UTF8, "application/json"); HttpClient client2 = new HttpClient(); var result2 = await client2.PostAsync("http://dearjean.ddns.net:44301/api/Points3/Change", content2); if (result2.StatusCode == HttpStatusCode.OK) { await DisplayAlert("Sukces", "Dodanie trasy przebiegło pomyślnie", "Ok"); } else { await DisplayAlert("Błąd", "Spróbuj ponownie później", "Ok"); } }
public void UISaveChangeModel(ChangeModel changeModel) { User user = mapper.Map <User>(userRepository.FindEntity((int)changeModel.Id)); //CurrentUser.BindingEmail = new Email(); //CurrentUser.Password = changeModel.UpdatePassword;//调用currentuser出现的问题 user.BindingEmail = new Email(); user.Password = changeModel.UpdatePassword; userRepository.UserSaveChanges(user); //更改密码出现问题cookie里面的密码与更改的密码发生冲突,试试出现添加cookie }
public ActionResult Change(ChangeModel model) { if (ModelState.IsValid) { var result = CusDao.Login(model.UserName, Encryptor.MD5Hash(model.Password)); if (result == true) { if (CusDao.CheckEmailUp(model.Email, model.UserName) == false) { ModelState.AddModelError("", "Đã có người sử dụng email này"); } else { var cus = new Customer(); cus.ID = model.Id; cus.Username = model.UserName; cus.Pass = Encryptor.MD5Hash(model.NewPassword); cus.Name = model.Name; cus.Phone = model.Phone; cus.Email = model.Email; cus.Address = model.Address; var result1 = CusDao.UpdateCus(cus); if (result1 == true) { ViewBag.Suc = "Thay đổi thành công"; var user = CusDao.GetByUN(model.UserName); var userSession = ""; var phone = ""; var mail = ""; var name = ""; var address = ""; userSession = user.Username; phone = user.Phone; mail = user.Email; name = user.Name; address = user.Address; Session.Add(CommonConstants.USER_SESSION, userSession); Session.Add(CommonConstants.Phone, phone); Session.Add(CommonConstants.Mail, mail); Session.Add(CommonConstants.Name, name); Session.Add(CommonConstants.Address, address); } else { ModelState.AddModelError("", "Thay đổi thất bại"); } } } else { ModelState.AddModelError("", "Sai mật khẩu"); } } return(View(model)); }
public ActionResult Change(ChangeModel model) { if (passwordService.GetUserPassword() != model.FormerPassword.MD5Crypt()) { ModelState.AddModelError(model.FormerPassword, "原来的密码不对,请好好想一想哦"); return(View(model)); } model.NewPassword = model.NewPassword.MD5Crypt(); passwordService.AddNewPwd(model); return(View()); }
public IActionResult Change() { ChangeModel q = new ChangeModel { user = (from p in bc.Persons where p.Email == HttpContext.User.Identity.Name select p).FirstOrDefault() }; return(View(q)); }
private void InsertVariationColumn(int x) { var i = _iterations.Count - 1; var columnSeries = ChangeModel.Series[0] as ColumnSeries; if (columnSeries != null) { columnSeries.Items.Add(new ColumnItem(x, i)); } ChangeModel.InvalidatePlot(true); }
public ActionResult ChangePasswordOnly(string id) { // Change password only ChangeModel model = new ChangeModel(true); model.WebApplicationDisplayName = "Web SSO Viewer"; model.SignOnAttemptId = id; model.CancelAllowed = true; model.CaptchaRequired = false; return View(model); }
public ActionResult ChangePasswordOnly(string id) { // Change password only ChangeModel model = new ChangeModel(true); model.WebApplicationDisplayName = "Web SSO Viewer"; model.SignOnAttemptId = id; model.CancelAllowed = true; model.CaptchaRequired = false; return(View(model)); }
//新老密码更替 public void AddNewPwd(ChangeModel model) { try { user = userRepository.Find(CurrentUserId); user.Password = model.NewPassword; } catch (Exception) { throw; } }
public ChangeModel CalculateChange(int pay, int amount) { if (pay < 0 || amount < 0 || pay < amount) { return(null); } var change = new ChangeModel(); change.Change = pay - amount; var remainChange = change.Change; if (remainChange >= 1000) { change.Tousand = remainChange / 1000; remainChange = remainChange % 1000; } if (remainChange >= 500) { change.FiveHundred = remainChange / 500; remainChange = remainChange % 500; } if (remainChange >= 100) { change.Hundred = remainChange / 100; remainChange = remainChange % 100; } if (remainChange >= 50) { change.Fifty = remainChange / 50; remainChange = remainChange % 50; } if (remainChange >= 20) { change.Twenty = remainChange / 20; remainChange = remainChange % 20; } if (remainChange >= 5) { change.Five = remainChange / 5; remainChange = remainChange % 5; } if (remainChange >= 1) { change.One = remainChange / 1; remainChange = remainChange % 1; } return(change); }
public ChangeModel ChangeDTOToChangeModel(ChangeDTO changeDTO) { ChangeModel changeModel = new ChangeModel { Email = changeDTO.Email, Img = changeDTO.Img, Login = changeDTO.Login, NewPassword = changeDTO.NewPassword, OldPassword = changeDTO.OldPassword, RepeatPassword = changeDTO.RepeatPassword, Token = changeDTO.Token }; return(changeModel); }
public ChangeDTO ChangeModelToChangeDTO(ChangeModel changeModel) { ChangeDTO changeDTO = new ChangeDTO { Token = MyUser.User.UserToken, Email = changeModel.Email, Img = changeModel.Img, Login = changeModel.Login, NewPassword = changeModel.NewPassword, OldPassword = changeModel.OldPassword, RepeatPassword = changeModel.RepeatPassword }; return(changeDTO); }
public User ChangeModelToUser(ChangeModel changeModel) { User user = new User { UserEmail = changeModel.Email, UserImg = changeModel.Img, UserLogin = changeModel.Login, UserPassword = changeModel.NewPassword, UserId = UsersData.UserList.Accounts[changeModel.Token].Id, UserPhoneNumber = UsersData.UserList.Accounts[changeModel.Token].PhoneNumber, UserRole = UsersData.UserList.Accounts[changeModel.Token].Role }; return(user); }
public bool ChangeAccount(ChangeModel model) { IService service = new WCFService(); IUserMap userMap = new Map(); if (service.ChangeAccount(userMap.ChangeModelToChangeDTO(model))) { MyUser.User.UserEmail = model.Email; MyUser.User.UserImg = model.Img; MyUser.User.UserPassword = model.NewPassword; return(true); } return(false); }
public async Task <ActionResult> Index(ChangeModel model) { if (ModelState.IsValid) { string userId = User.Identity.GetUserId(); if (model.Email != null) { var user = await UserManager.FindByIdAsync(userId); user.Email = model.Email; user.UserName = model.Email; IdentityResult emailResult = await UserManager.UpdateAsync(user); //IdentityResult nameResult = await UserManager. if (!emailResult.Succeeded) // TODO: иначе выводить "емаил успешно изменен" { foreach (var error in emailResult.Errors) { ModelState.AddModelError("", error); } ModelState.AddModelError("", "Почта не обновлена."); } } if (model.Password != null) { var provider = new DpapiDataProtectionProvider("TaskScheduler"); UserManager.UserTokenProvider = new DataProtectorTokenProvider <ApplicationUser>( provider.Create("PasswordReset")); string resetToken = await UserManager.GeneratePasswordResetTokenAsync(userId); IdentityResult passwordChangeResult = await UserManager.ResetPasswordAsync(userId, resetToken, model.Password); if (!passwordChangeResult.Succeeded) // TODO: иначе выводить "пароль успешно изменен" { foreach (var error in passwordChangeResult.Errors) { ModelState.AddModelError("", error); } ModelState.AddModelError("", "Пароль не изменен."); } } } model.Password = null; model.PasswordConfirm = null; return(View(model)); }
public ActionResult Change(ChangeModel model)//映射太少 破坏数据库的完整性 { ChangeModel RepoModel = _passwordService.GetChangeModelById((int)currentId); if (model.PresentPassword.MD5Encrypt() != RepoModel.PresentPassword) { ModelState.AddModelError(nameof(model.PresentPassword), "* 密码不正确,请检查密码并重新输入"); return(View(model)); } if (!ModelState.IsValid) { return(View(model)); } RepoModel.UpdatePassword = model.UpdatePassword.MD5Encrypt(); _passwordService.UISaveChangeModel(RepoModel);//更改密码出现问题cookie里面的密码与更改的密码发生冲突,试试出现添加cookie CookieHelper.RemoveCookie(); CookieHelper.AddCookie((int)RepoModel.Id, model.UpdatePassword); return(View()); }
public async Task <IActionResult> ChangeInfo(ChangeModel model) { if (ModelState.IsValid) { string path_Root = _appEnvironment.WebRootPath; User user = await db.Users.FirstOrDefaultAsync(u => u.Email == model.Email); if (user != null) { // добавляем пользователя в бд if ((model.Photo != null) && (model.Photo.ContentType == "image/jpeg" || model.Photo.ContentType == "image/png" || model.Photo.ContentType == "image/tiff" || model.Photo.ContentType == "image/gif" || model.Photo.ContentType == "image/bmp")) { string path_to_Images = path_Root + "\\img\\" + model.Photo.FileName; using (var stream = new FileStream(path_to_Images, FileMode.Create)) { await model.Photo.CopyToAsync(stream); } user.Photo = model.Photo.FileName; } else { user.Name = model.Name; user.Surname = model.Surname; await db.SaveChangesAsync(); return(RedirectToAction("Account", "Account")); } user.Name = model.Name; user.Surname = model.Surname; await db.SaveChangesAsync(); return(RedirectToAction("Account", "Account")); } else { ModelState.AddModelError("", user.Email); } } return(View()); }
public bool ChangeAccount(ChangeDTO changeDTO) { IMainMap map = new Map(); ChangeModel model = map.ChangeDTOToChangeModel(changeDTO); if (model.Img == null) { return(false); } if (model.Email == null) { return(false); } if (model.NewPassword == null) { return(false); } if (model.OldPassword == null) { return(false); } if (model.RepeatPassword == null) { return(false); } if (model.NewPassword != model.RepeatPassword) { return(false); } if (model.OldPassword != UsersData.UserList.Accounts[model.Token].Password) { return(false); } using (UserRepository repository = new UserRepository()) { IMapUser mapSign = new Map(); repository.Update(map.ChangeModelToUser(model)); repository.Save(); UsersData.UserList.Accounts[model.Token] = mapSign.UserToAccountModel(map.ChangeModelToUser(model)); return(true); } }
public ActionResult Change(string id) { // Change password and security questions ChangeModel model = new ChangeModel(false); model.WebApplicationDisplayName = "Web SSO Viewer"; model.SignOnAttemptId = id; model.CancelAllowed = true; model.CaptchaRequired = false; model.UserSecurityQuestions1 = SecurityQuestions.Items; model.UserSecurityQuestions2 = SecurityQuestions.Items; model.UserSecurityQuestions3 = SecurityQuestions.Items; model.SecurityAnswer1 = "●●●●●●●●"; model.SecurityAnswer2 = "●●●●●●●●"; model.SecurityAnswer3 = "●●●●●●●●"; return View(model); }
public ActionResult Change(string id) { // Change password and security questions ChangeModel model = new ChangeModel(false); model.WebApplicationDisplayName = "Web SSO Viewer"; model.SignOnAttemptId = id; model.CancelAllowed = true; model.CaptchaRequired = false; model.UserSecurityQuestions1 = SecurityQuestions.Items; model.UserSecurityQuestions2 = SecurityQuestions.Items; model.UserSecurityQuestions3 = SecurityQuestions.Items; model.SecurityAnswer1 = "●●●●●●●●"; model.SecurityAnswer2 = "●●●●●●●●"; model.SecurityAnswer3 = "●●●●●●●●"; return(View(model)); }
public async Task <IActionResult> Change(ChangeModel model) { Person person = new Person(); if (ModelState.IsValid) { person = await bc.Persons.FirstOrDefaultAsync(u => u.Email == HttpContext.User.Identity.Name); if (person != null) { person.FirstName = model.FirstName; person.LastName = model.LastName; await bc.SaveChangesAsync(); } else { return(RedirectToAction("Register", "Account")); } } return(RedirectToAction("Index", "Profile")); }
public static Change Convert(this ChangeModel model) { var change = new Change { Id = model.Id, Version = model.Version, Username = model.Username, Date = model.Date, Href = model.Href, WebUrl = model.WebUrl, Comment = model.Comment, User = model.User, VcsRootInstance = model.VcsRootInstance }; if (model.Files?.File != null) { change.Files = model.Files.File; } return(change); }
private async void OnNewRouteClicked(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(trasaEntry.Text)) { await DisplayAlert("Błąd", "Podaj nazwę trasy", "Ok"); return; } List <int> idList = new List <int>(); foreach (Points tmp in routePoints) { var json = JsonConvert.SerializeObject(tmp); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpClient client = new HttpClient(); var result = await client.PostAsync("http://dearjean.ddns.net:44301/api/Points3", content); var pointResult = JsonConvert.DeserializeObject <Points>(result.Content.ReadAsStringAsync().Result); if (result.StatusCode != HttpStatusCode.Created) { await DisplayAlert("Błąd", "Spróbuj ponownie później", "Ok"); Debug.WriteLine(result); return; } idList.Add(pointResult.Id); } var model = new ChangeModel { UpdateList = idList, Name = trasaEntry.Text, Description = opistrasyEntry.Text }; var json2 = JsonConvert.SerializeObject(model); var content2 = new StringContent(json2, Encoding.UTF8, "application/json"); HttpClient client2 = new HttpClient(); await client2.PostAsync("http://dearjean.ddns.net:44301/api/Points3/Change", content2); }
public void ChangeModel_Convert_AllPropertiesPopulated() { // Arrange var changeModel = new ChangeModel() { Id = 1, Version = "123", Username = "******", Date = new DateTime(2017, 1, 1), Href = "test", WebUrl = "test", Comment = "test", User = new User(), Files = new Files() { File = new List <File>() { new File() { RelativeFile = "something" } } }, VcsRootInstance = new VcsRootInstance() }; // Act var change = changeModel.Convert(); // Assert foreach (var propertyInfo in change.GetType().GetProperties()) { var defaultValue = GetDefault(propertyInfo.PropertyType); var actualValue = propertyInfo.GetValue(change); actualValue.Should().NotBe(defaultValue, $"because ChangeModel::{propertyInfo.Name} should have been mapped property from ChangeModel to Change in Conventer"); } }
public ActionResult AddChange() { ChangeModel model = new ChangeModel(); List <ChangeTypeDTO> dtolist = changetypeService.GetList(); if (dtolist != null) { model.changetypeList = dtolist; } var selectItemList = new List <SelectListItem>() { new SelectListItem() { Value = "0", Text = "请选择", Selected = true } }; var selectList = new SelectList(model.changetypeList, "ID", "TypeName"); selectItemList.AddRange(selectList); ViewBag.dropchagelist = selectItemList; return(View(model)); }
private async void OnNewRouteClicked(object sender, EventArgs e) { if (routePoints.Count() == 0) { await DisplayAlert("Błąd", "Dodaj punkt na mapę", "Ok"); return; } if (String.IsNullOrWhiteSpace(trasaEntry.Text)) { await DisplayAlert("Błąd", "Podaj nazwę trasy", "Ok"); return; } if (routePoints.Count() > 11) // dodatkowe zabezpieczenie na przycisk, nie moze byc > 10 bo wyswietla niepotrzebnie błąd { await DisplayAlert("Błąd", "Można do trasy dodać maksymalnie 10 punktów", "Ok"); return; } try { List <int> idList = new List <int>(); foreach (Points tmp in routePoints) { var token1 = Application.Current.Properties["MyToken"].ToString(); var json = JsonConvert.SerializeObject(tmp); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token1); var result = await client.PostAsync("http://dearjean.ddns.net:44301/api/Points3", content); var pointResult = JsonConvert.DeserializeObject <Points>(result.Content.ReadAsStringAsync().Result); if (result.StatusCode != HttpStatusCode.Created) { await DisplayAlert("Błąd", "Spróbuj ponownie później", "Ok"); Debug.WriteLine(result); return; } idList.Add(pointResult.Id); } var model = new ChangeModel { UpdateList = idList, Name = trasaEntry.Text, Description = opistrasyEntry.Text }; var json2 = JsonConvert.SerializeObject(model); var content2 = new StringContent(json2, Encoding.UTF8, "application/json"); var token = Application.Current.Properties["MyToken"].ToString(); HttpClient client2 = new HttpClient(); client2.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var result2 = await client2.PostAsync("http://dearjean.ddns.net:44301/api/Points3/Change", content2); if (result2.StatusCode == HttpStatusCode.OK) { await DisplayAlert("Sukces", "Dodanie trasy przebiegło pomyślnie", "Ok"); } else { await DisplayAlert("Błąd", "Nie masz odpowiednich uprawnień na kreatora! Skontaktuj się z administratorem", "Ok"); } } catch (Exception xd) { await DisplayAlert("Uwaga!", "Nie masz odpowiednich uprawnień na kreatora! Skontaktuj się z administratorem", "Anuluj"); } }