public void Setup() { _context = ShimsContext.Create(); _edit = new edit(); _privateEditObject = new PrivateObject(_edit); _privatePageObject = new PrivateObject(_edit, new PrivateType(typeof(Page))); _privateUnsecuredPageObject = new PrivateObject(_edit, new PrivateType(typeof(UnsecuredLayoutsPageBase))); }
private void dgvxTakeAway_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2 && dgvxTakeAway.RowCount != 0) { edit ed = new edit(this, e.RowIndex, e.ColumnIndex); ed.ShowDialog(); } }
public int editusername([FromBody] edit request) { DbHelper db = new DbHelper(); List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(new DbParameter("username", System.Data.ParameterDirection.Input, request.username)); parameters.Add(new DbParameter("id", System.Data.ParameterDirection.Input, request.id)); var result = db.ExecuteNonQuery("edit_username", parameters); return(result); }
public async Task <ActionResult> edit_profile(string id) { try { var cuurent_ID = User.Identity.GetUserId(); ViewBag.employee = dbcontext.Employee_Profile.ToList().Select(m => new { Code = "" + m.Code + "--[" + m.Full_Name + ']', ID = m.ID }).ToList(); if (id != null) ///يفتح { var Login_User1 = await UserManager.FindByIdAsync(id.ToString()); edit user_edit1 = new edit(); user_edit1.name = Login_User1.UserName; user_edit1.mail = Login_User1.Email; user_edit1.image_profile = Login_User1.ImagePath; user_edit1.company_name = Login_User1.company_name; user_edit1.employee_o = (int)Login_User1.employee_o; user_edit1.active = Login_User1.active; user_edit1.id = Login_User1.Id; ViewBag.flag = true; return(View(user_edit1)); } else { var userId = User.Identity.GetUserId(); var Login_User = await UserManager.FindByIdAsync(userId); edit user_edit = new edit(); user_edit.id = Login_User.Id; user_edit.name = Login_User.UserName; user_edit.mail = Login_User.Email; user_edit.image_profile = Login_User.ImagePath; user_edit.company_name = Login_User.company_name; user_edit.active = Login_User.active; return(View(user_edit)); } } catch (Exception e) { return(RedirectToAction("index", "Home")); } }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here string username = collection["username"]; var edit = new edit { username = username, id = id }; var respPost = RequestHelper.MakePostRequest <int>("test/editusername/", edit); return(RedirectToAction("Index")); } catch { return(View()); } }
public bool editLetter(int letter_id, string new_letter, string userip, string cookie_value, string user_name, bool is_user_mod) { db_mysql db_mysql = new db_mysql(); db_mssql db_mssql = new db_mssql(); Letter lucky = getLetter(letter_id); letter lucky_letter = Mapper.Map<Letter, letter>(lucky); HtmlUtility utility = HtmlUtility.Instance; edit new_edit = new edit(); new_edit.editComment = "Edited by " + user_name; new_edit.editor = user_name; new_edit.editDate = DateTime.Now; String letter_contents = utility.SanitizeHtml(new_letter); letter_contents = letter_contents.Replace("text-decoration%3a%20line-through%3b", "text-decoration: line-through"); letter_contents = letter_contents.Replace("text-decoration%3a%20underline%3b", "text-decoration: underline;"); new_edit.newLetter = letter_contents; new_edit.previousLetter = lucky.letterMessage; new_edit.status = "accepted"; new_edit.letterID = lucky.Id; new_edit.editDate = DateTime.UtcNow; db_mssql.edits.Add(new_edit); db_mysql.letters.Attach(lucky_letter); var letter = db_mysql.Entry(lucky_letter); letter.Property(e => e.letterMessage).IsModified = true; lucky_letter.letterMessage = letter_contents; db_mysql.SaveChanges(); db_mssql.SaveChanges(); return true; }
public bool editComment(string commentText, int id, string commenter_guid, string user_name) { db_mysql db_mysql = new db_mysql(); db_mssql db_mssql = new db_mssql(); Comment lucky_comment = getComment(id); comment comment = Mapper.Map<Comment, comment>(lucky_comment); HtmlUtility utility = HtmlUtility.Instance; edit new_edit = new edit(); new_edit.editComment = "Comment edited by " + user_name; new_edit.editor = user_name; new_edit.editDate = DateTime.Now; String comment_contents = utility.SanitizeHtml(commentText); new_edit.newLetter = comment_contents; new_edit.previousLetter = lucky_comment.commentMessage; new_edit.status = "accepted"; new_edit.letterID = lucky_comment.letterId; new_edit.editDate = DateTime.UtcNow; db_mssql.edits.Add(new_edit); db_mysql.comments.Attach(comment); var comment_var = db_mysql.Entry(comment); comment_var.Property(e => e.commentMessage).IsModified = true; comment.commentMessage = comment_contents; db_mysql.SaveChanges(); db_mssql.SaveChanges(); return true; }
public Letter PublishQueue() { db_mssql db_mssql = new db_mssql(); db_mysql db_mysql = new db_mysql(); List<Queued> qry = (from m in db_mssql.Queueds where m.State == 0 orderby m.LetterID ascending select m).ToList(); if (qry.Count() == 0) { return null; } Queued latest_unpublished_queued = qry.First(); letter latest_front_page = (from l in db_mysql.letters where l.letterLevel == 1 orderby l.letterPostDate descending select l).First(); letter lucky_letter = (from l in db_mysql.letters where l.Id == latest_unpublished_queued.LetterID select l).FirstOrDefault(); if (lucky_letter == null) { return null; } db_mysql.letters.Attach(lucky_letter); var letter = db_mysql.Entry(lucky_letter); letter.Property(e => e.letterLevel).IsModified = true; lucky_letter.letterLevel = 1; db_mssql.Queueds.Attach(latest_unpublished_queued); var queued = db_mssql.Entry(latest_unpublished_queued); queued.Property(e => e.State).IsModified = true; latest_unpublished_queued.State = 1; db_mysql.SaveChanges(); db_mssql.SaveChanges(); edit new_edit = new edit(); new_edit.editComment = "Published from queue."; new_edit.previousLetter = lucky_letter.letterMessage; new_edit.newLetter = lucky_letter.letterMessage; new_edit.editDate = DateTime.Now; new_edit.letterID = lucky_letter.Id; new_edit.status = "accepted"; new_edit.editor = "auto post"; db_mssql.edits.Add(new_edit); db_mssql.SaveChanges(); return Mapper.Map<letter, Letter>(lucky_letter); }
public void Queue(int letter_id, string user_name) { db_mssql db_mssql = new db_mssql(); db_mysql db_mysql = new db_mysql(); letter lucky = (from m in db_mysql.letters where m.Id.Equals(letter_id) select m).FirstOrDefault(); if (lucky != null) { edit new_edit = new edit(); new_edit.editComment = "Added to queue by " + user_name; new_edit.editor = user_name; new_edit.newLetter = lucky.letterMessage; new_edit.previousLetter = lucky.letterMessage; new_edit.status = "accepted"; new_edit.letterID = lucky.Id; new_edit.editDate = DateTime.UtcNow; Queued new_queued_letter = new Queued(); new_queued_letter.AddedToQueueDate = DateTime.UtcNow; new_queued_letter.LetterID = lucky.Id; new_queued_letter.PostDate = DateTime.UtcNow; new_queued_letter.QueueID = lucky.Id; new_queued_letter.State = 0; db_mssql.Queueds.Add(new_queued_letter); db_mssql.edits.Add(new_edit); db_mssql.SaveChanges(); } }
public bool unhideComment(int id, string commenter_guid, string user_name) { db_mysql db_mysql = new db_mysql(); db_mssql db_mssql = new db_mssql(); Comment lucky_comment = getComment(id); comment comment = Mapper.Map<Comment, comment>(lucky_comment); letter letter = (from m in db_mysql.letters where m.Id.Equals(lucky_comment.letterId) select m).FirstOrDefault(); HtmlUtility utility = HtmlUtility.Instance; edit new_edit = new edit(); new_edit.editComment = "Comment un-hidden by " + user_name; new_edit.editor = user_name; new_edit.editDate = DateTime.Now; new_edit.newLetter = lucky_comment.commentMessage; new_edit.previousLetter = lucky_comment.commentMessage; new_edit.status = "accepted"; new_edit.letterID = lucky_comment.letterId; new_edit.editDate = DateTime.UtcNow; db_mssql.edits.Add(new_edit); db_mysql.comments.Attach(comment); db_mysql.letters.Attach(letter); var comment_var = db_mysql.Entry(comment); var letter_var = db_mysql.Entry(letter); comment_var.Property(e => e.level).IsModified = true; comment.level = 0; letter_var.Property(e => e.letterComments).IsModified = true; letter.letterComments = letter.letterComments + 1; db_mysql.SaveChanges(); db_mssql.SaveChanges(); return true; }
public async Task <ActionResult> edit_profile(edit model, HttpPostedFileBase file, string Command) { var cuurent_ID = User.Identity.GetUserId(); ViewBag.employee = dbcontext.Employee_Profile.ToList().Select(m => new { Code = "" + m.Code + "--[" + m.Full_Name + ']', ID = m.ID }).ToList(); var userId = model.id; var Login_User = await UserManager.FindByIdAsync(userId); model.image_profile = Login_User.ImagePath; // model.company_name = Login_User.company_name; if (!ModelState.IsValid) { TempData["Message"] = "ERROR."; if (cuurent_ID != model.id) { return(RedirectToAction("edit_profile", new { id = model.id })); } else { return(View(model)); } } try { Login_User.UserName = model.name; Login_User.Email = model.mail; Login_User.company_name = model.company_name; Login_User.active = model.active; if (model.employee_o != 0) { var id_em = model.employee_o; Login_User.employee_name = dbcontext.Employee_Profile.FirstOrDefault(m => m.ID == id_em).Full_Name; Login_User.employee_o = model.employee_o; } else { if (cuurent_ID != model.id) { return(RedirectToAction("edit_profile", "account", new { id = model.id })); } } if (model.image_profile != null) { Login_User.ImagePath = model.image_profile; } if (file != null && file.ContentLength > 0) { var supportedTypes = new[] { "jpg", "jpeg", "png" }; var fileName = Path.GetExtension(file.FileName); if (fileName != null) { var fileExt = fileName.Substring(1); if (!supportedTypes.Contains(fileExt)) { TempData["Message"] = "Invalid image type. Only the following types (jpg, jpeg, png) are supported."; if (cuurent_ID != model.id) { return(RedirectToAction("edit_profile", new { id = model.id })); } else { return(View(model)); } } var photoName = Guid.NewGuid().ToString("N") + "." + fileExt; var photo = Server.MapPath("~/Images/Users/") + photoName; file.SaveAs(photo); Login_User.ImagePath = "/Images/Users/" + photoName; } } if (!string.IsNullOrEmpty(model.password) && !string.IsNullOrEmpty(model.new_password) && model.new_password == model.confirmpassword) { var result = await UserManager.ChangePasswordAsync(userId, model.password, model.new_password); if (!result.Succeeded) { AddErrors(result); if (cuurent_ID != model.id) { return(RedirectToAction("edit_profile", new { id = model.id })); } else { return(View(model)); } } await SignInManager.SignInAsync(Login_User, isPersistent : false, rememberBrowser : false); } else if (!string.IsNullOrEmpty(model.new_password) && model.new_password != model.confirmpassword) { TempData["Message"] = "new password not matching"; if (cuurent_ID != model.id) { return(RedirectToAction("edit_profile", new { id = model.id })); } else { return(View(model)); } } else { TempData["Message"] = "password not updated"; } var result1 = await UserManager.UpdateAsync(Login_User); if (!result1.Succeeded) { AddErrors(result1); if (cuurent_ID != model.id) { return(RedirectToAction("edit_profile", new { id = model.id })); } else { return(View(model)); } } TempData["msg"] = "Profile Changes Saved !"; if (Command == "link") { return(RedirectToAction("link", "groupinfo", new { userid = Login_User.Id })); } else if (cuurent_ID != model.id) { return(RedirectToAction("all", "Account")); } else { return(RedirectToAction("index", "Home")); } } catch (Exception e) { TempData["Message"] = "ERROR."; return(View(model)); } }
private void vehicle_list_box_DoubleClick(object sender, EventArgs e) { edit vehicle_window = new edit(vehicle_list_box, "vehicle"); vehicle_window.Show(); }
private void kids_list_box_DoubleClick(object sender, EventArgs e) { edit window = new edit(kids_list_box, "kid"); window.Show(); }
public void unhideLetter(int lucky_id, string userip, string cookie_value, string user_name, bool is_user_mod) { db_mysql db_mysql = new db_mysql(); db_mssql db_mssql = new db_mssql(); Letter lucky = getLetter(lucky_id); if (lucky == null) { return; } edit new_edit = new edit(); new_edit.editComment = "Unhidden by " + user_name; new_edit.editor = user_name; new_edit.newLetter = lucky.letterMessage; new_edit.previousLetter = lucky.letterMessage; new_edit.status = "accepted"; new_edit.letterID = lucky.Id; new_edit.editDate = DateTime.UtcNow; db_mssql.edits.Add(new_edit); letter transformed; transformed = Mapper.Map<Letter, letter>(lucky); db_mysql.letters.Attach(transformed); var letter = db_mysql.Entry(transformed); letter.Property(e => e.letterLevel).IsModified = true; transformed.letterLevel = 0; letter.CurrentValues.SetValues(transformed); db_mysql.SaveChanges(); }