public async Task Index_ReturnsAViewResult_WithAboutMeModel() { //Arrange var technologyLogicMock = new Mock <ITechnologyLogic>(); var aboutMeLogicMock = new Mock <IAboutMeLogic>(); var modelToReturn = new AboutMe() { AboutMeId = 1, ImageLink = "link", Title = "Title", Text = "Text" }; aboutMeLogicMock.Setup(logic => logic.GetAboutMeAsync()).ReturnsAsync(modelToReturn); AboutMeController controllerUnderTests = new AboutMeController(aboutMeLogicMock.Object, technologyLogicMock.Object); //Act var result = await controllerUnderTests.Index(); //Assert var viewResult = Assert.IsType <ViewResult>(result); var returnedModel = Assert.IsAssignableFrom <AboutMe>(viewResult.ViewData.Model); ComparisonResult res = MyComparer.Compare(modelToReturn, returnedModel); Assert.True(res.AreEqual); }
public IActionResult Edit(Guid id, AboutMeViewModel model) { if (id != model.Id) { return(NotFound()); } if (ModelState.IsValid) { try { AboutMe aboutMe = new AboutMe { Id = model.Id, Section1 = model.Section1, Section2 = model.Section2 }; _aboutMe.Entity.Update(aboutMe); _aboutMe.Save(); } catch (DbUpdateConcurrencyException) { if (!AboutMeExists(model.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(model)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Paragraph")] AboutMe aboutMe) { if (id != aboutMe.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(aboutMe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AboutMeExists(aboutMe.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aboutMe)); }
public async Task <IActionResult> Update(int id) { ViewBag.MessageCount = db.MessageMe.Count(); AboutMe about = await db.AboutMe.FindAsync(id); return(View(about)); }
// PUT api/AboutMeAPI/5 public HttpResponseMessage PutAboutMe(int id, AboutMe aboutme) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != aboutme.AboutMeId) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(aboutme).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public ActionResult AboutMe() { AboutMe c = _repository.GetAll().FirstOrDefault(); AboutMeViewModel aboutMeViewModel = Mapper.Map <AboutMe, AboutMeViewModel>(c); return(View(aboutMeViewModel)); }
public async Task <bool> UpdateAboutMeAsync(AboutMe aboutMe) { StringBuilder query = new StringBuilder(); query.Append("UPDATE "); query.Append($"{TableName} "); query.Append("SET "); query.Append("[ImageLink] = @ImageLink "); query.Append(",[Text] = @Text "); query.Append(",[Title] = @Title "); try { using (IDbConnection connection = _manager.GetSqlConnection()) { var result = await connection.ExecuteAsync(query.ToString(), new { aboutMe.ImageLink, aboutMe.Text, aboutMe.Title }); return(result > 0); } } catch (Exception e) { Logger.Log(e); } return(false); }
public JsonResult AboutMeFillData(int?Type, AboutMe ab) { bool Status = false; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); SqlCommand cmd = new SqlCommand("select * from [AboutMe] where DescriptionType='" + Type + "'", con); cmd.ExecuteNonQuery(); con.Close(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); if (dt.Rows.Count > 0) { Status = true; } foreach (DataRow dr in dt.Rows) { ab.AboutMeId = Convert.ToInt32(dr["AboutMeId"]); int e = Convert.ToInt32(dr["DescriptionType"]); ab.DescriptionType = (AboutMe.EnumDescriptionType)Enum.ToObject(typeof(AboutMe.EnumDescriptionType), e); ab.AboutMeDescription = dr["AboutMeDescription"].ToString(); } } return(Json(new { Status, ab.AboutMeId, ab.DescriptionType, ab.AboutMeDescription })); }
public async Task <IActionResult> Edit(AboutMe aboutMe, IFormFile imageFile) { if (!ModelState.IsValid) { return(View("Index", aboutMe)); } if (imageFile != null) { var newImageName = await _pictureService.EditAboutMeImageAsync(imageFile, aboutMe.Image); if (string.IsNullOrEmpty(newImageName)) { TempData["Error"] = "حجم عکس بیش از 500 کیلوبایت می باشد"; return(RedirectToAction("Index")); } aboutMe.Image = newImageName; } _db.AboutMe.Update(aboutMe); await _db.SaveChangesAsync(); TempData["Success"] = "اطلاعات با موفقیت ذخیره شد"; return(RedirectToAction("Index")); }
public ActionResult AboutMeIndex(AboutMe ab) { try { using (SqlConnection con = new SqlConnection(cs)) { con.Open(); SqlCommand cmd = new SqlCommand("InsertUpdateAboutMe", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@aboutMeId", ab.AboutMeId); cmd.Parameters.AddWithValue("@descriptionType", (int)ab.DescriptionType); cmd.Parameters.AddWithValue("@aboutMeDescription", ab.AboutMeDescription); cmd.ExecuteNonQuery(); con.Close(); } ViewBag.Message = "Description added susseccfully"; ViewBag.Status = "alert-success"; } catch (Exception ex) { ViewBag.Message = "Oops! something went wrong"; ViewBag.Status = "alert-danger"; } return(View()); }
private void button8_Click(object sender, EventArgs e) { int version = JsBridge.LibVersion; #if DEBUG JsBridge.dbugTestCallbacks(); #endif using (JsEngine engine = new JsEngine()) using (JsContext ctx = engine.CreateContext(new MyJsTypeDefinitionBuilder())) { GC.Collect(); System.Diagnostics.Stopwatch stwatch = new System.Diagnostics.Stopwatch(); stwatch.Reset(); stwatch.Start(); var ab = new AboutMe(); ctx.SetVariableAutoWrap("x", ab); string testsrc = @"(function(){ x.AttachEvent('mousedown',function(evArgs){}); x.FireEventMouseDown({}); })()"; object result = ctx.Execute(testsrc); stwatch.Stop(); Console.WriteLine("met1 template:" + stwatch.ElapsedMilliseconds.ToString()); } }
public void Put(string id, [FromBody] AboutMe aboutMe) { if (IsExist(id)) { _aboutMeService.Update(id, aboutMe); } }
void DisplayPanel(object _child) { if (!_child.ToString().Equals(panelMain.Name)) { foreach (UserControl c in panelMain.Controls) { ((IFormPanelChild)c).Hide(); } if (_child.ToString().Equals(typeof(PanelListPatient).Name)) { panelListPatient.RefeshDataTable(null); panelListPatient.Show(); lblNaviBar2.Visible = true; lblNaviBar2.Text = "Danh sách"; } else { if (_child.ToString().Equals(typeof(PanelHome).Name)) { panelHome.Show(); lblNaviBar2.Visible = false; lblNaviBar2.Text = "Empty"; } else { if (_child.ToString().Equals("Backup")) { PanelFunction panelFunction = new PanelFunction(); panelFunction.Dock = DockStyle.Fill; panelMain.Controls.Add(panelFunction); panelFunction.Show(); lblNaviBar2.Visible = true; lblNaviBar2.Text = "Backup"; } else { this.Hide(); Form aboutForm = new Form(); AboutMe aboutMe = new AboutMe(); aboutMe.Dock = DockStyle.Fill; aboutForm.Size = aboutMe.Size; aboutForm.WindowState = FormWindowState.Normal; aboutForm.StartPosition = FormStartPosition.CenterScreen; aboutForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; aboutForm.Controls.Add(aboutMe); aboutForm.ShowDialog(); this.Show(); panelHome.Show(); lblNaviBar2.Visible = false; lblNaviBar2.Text = "Empty"; panelMain.Name = typeof(PanelHome).Name; return; } } } panelMain.Name = _child.ToString(); } }
public ActionResult EditAboutMe(int?gelenId) { AboutMe me = Model.AboutMe.Find(gelenId); ViewBag.AboutId = me.Id; ViewBag.Context = me.AboutMeText; return(View()); }
public ActionResult DeleteConfirmed(int id) { AboutMe aboutMe = db.AboutMes.Find(id); db.AboutMes.Remove(aboutMe); db.SaveChanges(); return(RedirectToAction("Home")); }
public async Task <IActionResult> Update(AboutMe about) { ViewBag.MessageCount = db.MessageMe.Count(); db.Entry(about).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
private void ribbonOrbMenuItem3_Click(object sender, EventArgs e) { DeleteTrash(); aboutMe = new AboutMe(values[0]); support.MoveDesignToPanel(aboutMe, panelMain); this.Controls.Add(aboutMe); aboutMe.BringToFront(); }
public ActionResult Edit([Bind(Include = "ID,Name,Date,Address,Nationality,Phone,Mail,Objective,WhatIDo")] AboutMe aboutMe) { if (ModelState.IsValid) { db.Entry(aboutMe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aboutMe)); }
public ActionResult Edit(AboutMe aboutme) { if (ModelState.IsValid) { db.Entry(aboutme).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aboutme)); }
public ActionResult Edit([Bind(Include = "id,MeName,MeProfile,MeEmail,MePhone,MeAbout")] AboutMe aboutMe) { if (ModelState.IsValid) { db.Entry(aboutMe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aboutMe)); }
public ActionResult Edit([Bind(Include = "id,FlipBoardTitle,FlipBoardSubTitle,FlipboardThumnbailUrl,Description")] AboutMe aboutMe) { if (ModelState.IsValid) { db.Entry(aboutMe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Home")); } return(View(aboutMe)); }
public ActionResult AboutMeGuncelle(AboutMe _boutMe) { var bme = c.AboutMes.Find(_boutMe.Id); bme.FotoUrl = _boutMe.FotoUrl; bme.Aciklama = _boutMe.Aciklama; c.SaveChanges(); return(RedirectToAction("AboutMeListesi")); }
// // GET: /AboutMe/Delete/5 public ActionResult Delete(int id = 0) { AboutMe aboutme = db.AboutMes.Find(id); if (aboutme == null) { return(HttpNotFound()); } return(View(aboutme)); }
public ActionResult Create([Bind(Include = "ID,Name,Date,Address,Nationality,Phone,Mail,Objective,WhatIDo")] AboutMe aboutMe) { if (ModelState.IsValid) { db.AboutMes.Add(aboutMe); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aboutMe)); }
// GET api/AboutMeAPI/5 public AboutMe GetAboutMe(int id) { AboutMe aboutme = db.AboutMes.Find(id); if (aboutme == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(aboutme); }
// GET: AboutMe public ActionResult Index() { ApplicationDbContext db = new ApplicationDbContext(); AboutMe aboutMe = (from u in db.AboutMe select u).FirstOrDefault(); AboutMeViewModel aboutMeViewModel = Mapper.Map <AboutMe, AboutMeViewModel>(aboutMe); return(View(aboutMeViewModel)); }
public ActionResult Create([Bind(Include = "id,MeName,MeProfile,MeEmail,MePhone,MeAbout")] AboutMe aboutMe) { if (ModelState.IsValid) { db.AboutMes.Add(aboutMe); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aboutMe)); }
public IActionResult Edit(int?id) { AboutMe post = repository.Get(id.Value); if (post == null) { return(NotFound()); } return(View(AboutMeForm, post)); }
public void GetTest_existing_aboutMe() { //Arrange //Act AboutMe result = _repository.Get(1); //Assert Assert.Equal(result, _aboutMe[0]); }
public AboutMe GetAboutMe() { using (IDbConnection dbConnection = Connection) { string aboutMeQuery = "SELECT aboutmetext FROM tblaboutme"; dbConnection.Open(); AboutMe am = new AboutMe(); am.AboutMeText = dbConnection.QueryFirstOrDefault <string>(aboutMeQuery); return(am); } }
void AboutAuthorToolStripMenuItemClick(object sender, EventArgs e) { System.Windows.Forms.Form f1 = System.Windows.Forms.Application.OpenForms["AboutMe"]; if(((AboutMe)f1)!=null) { am_frm.Focus(); } else { am_frm = new AboutMe(); am_frm.Show(); } }
private void button7_Click(object sender, EventArgs e) { JsBridge.dbugTestCallbacks(); using (JsEngine engine = new JsEngine()) using (JsContext ctx = engine.CreateContext(new MyJsTypeDefinitionBuilder())) { GC.Collect(); System.Diagnostics.Stopwatch stwatch = new System.Diagnostics.Stopwatch(); stwatch.Reset(); stwatch.Start(); var ab = new AboutMe(); ctx.SetVariableAutoWrap("x", ab); //string testsrc = "x.IsOK;"; string testsrc = "x.NewAboutMe();"; object result = ctx.Execute(testsrc); stwatch.Stop(); Console.WriteLine("met1 template:" + stwatch.ElapsedMilliseconds.ToString()); } }
private void button8_Click(object sender, EventArgs e) { int version = JsBridge.LibVersion; JsBridge.dbugTestCallbacks(); using (JsEngine engine = new JsEngine()) using (JsContext ctx = engine.CreateContext(new MyJsTypeDefinitionBuilder())) { GC.Collect(); System.Diagnostics.Stopwatch stwatch = new System.Diagnostics.Stopwatch(); stwatch.Reset(); stwatch.Start(); var ab = new AboutMe(); ctx.SetVariableAutoWrap("x", ab); string testsrc = @"(function(){ x.AttachEvent('mousedown',function(evArgs){}); x.FireEventMouseDown({}); })()"; object result = ctx.Execute(testsrc); stwatch.Stop(); Console.WriteLine("met1 template:" + stwatch.ElapsedMilliseconds.ToString()); } }
private void button9_Click(object sender, EventArgs e) { //------------------------ //test esprima package //------------------------ string esprima_code = File.ReadAllText("d:\\projects\\Espresso\\js_tools\\esprima\\esprima.js"); StringBuilder stbuilder = new StringBuilder(); stbuilder.Append(esprima_code); int version = JsBridge.LibVersion; JsBridge.dbugTestCallbacks(); using (JsEngine engine = new JsEngine()) using (JsContext ctx = engine.CreateContext(new MyJsTypeDefinitionBuilder())) { GC.Collect(); System.Diagnostics.Stopwatch stwatch = new System.Diagnostics.Stopwatch(); stwatch.Reset(); stwatch.Start(); var ab = new AboutMe(); ctx.SetVariableAutoWrap("aboutme1", ab); string testsrc = @"(function(){ var syntax= esprima.parse('var answer = 42'); //convert to json format and send to managed side aboutme1.SetResult(JSON.stringify(syntax, null, 4)); })()"; stbuilder.Append(testsrc); ctx.Execute(stbuilder.ToString()); stwatch.Stop(); Console.WriteLine("met1 template:" + stwatch.ElapsedMilliseconds.ToString()); } }
private void button5_Click(object sender, EventArgs e) { JsBridge.dbugTestCallbacks(); JsTypeDefinition jstypedef = new JsTypeDefinition("AA"); jstypedef.AddMember(new JsMethodDefinition("B", args => { var argCount = args.ArgCount; var thisArg = args.GetThisArg(); var arg0 = args.GetArgAsObject(0); args.SetResult((bool)arg0); })); jstypedef.AddMember(new JsMethodDefinition("C", args => { args.SetResult(true); })); //----------------------------------------------------- jstypedef.AddMember(new JsPropertyDefinition("D", args => { var ab = new AboutMe(); args.SetResultAutoWrap(ab); }, args => { //setter })); jstypedef.AddMember(new JsPropertyDefinition("E", args => { //getter args.SetResult(250); }, args => { //setter })); //=============================================================== //create js engine and context using (JsEngine engine = new JsEngine()) using (JsContext ctx = engine.CreateContext()) { ctx.RegisterTypeDefinition(jstypedef); GC.Collect(); System.Diagnostics.Stopwatch stwatch = new System.Diagnostics.Stopwatch(); stwatch.Reset(); stwatch.Start(); TestMe1 t1 = new TestMe1(); INativeScriptable proxy = ctx.CreateWrapper(t1, jstypedef); ctx.SetVariable("x", proxy); string testsrc = "x.B(x.D.IsOK);"; object result = ctx.Execute(testsrc); stwatch.Stop(); Console.WriteLine("met1 template:" + stwatch.ElapsedMilliseconds.ToString()); } }