public ActionResult EditSidebar(SidebarDto sidebar) { HttpResponseMessage response = GlobalVariables.WebApiClient.PutAsJsonAsync("Sidebars/" + sidebar.Id, sidebar).Result; TempData["SuccessMessage"] = "Updated Successfully"; return(RedirectToAction("EditSidebar")); }
public ActionResult EditSidebar() { SidebarVm model; SidebarDto dto = db.Sidebars.Find(1); model = new SidebarVm(dto); return(View(model)); }
public ActionResult EditSidebar() { using (Db db = new Db()) { SidebarDto dto = db.Sidebars.Find(1); SidebarViewModel model = new SidebarViewModel(dto); return(View(model)); } }
public IHttpActionResult PutSidebar(int id, SidebarDto sidebar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _sidebarService.Update(id, sidebar); return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostSidebar(SidebarDto sidebar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _sidebarService.Add(sidebar); return(CreatedAtRoute("DefaultApi", new { id = sidebar.Id }, sidebar)); }
// GET: Admin/Pages/EditSidebar public ActionResult EditSidebar() { SidebarViewModel sidebarViewModel; using (var db = new Db()) { SidebarDto dto = db.Sidebar.Find(1); sidebarViewModel = new SidebarViewModel(dto); } return(View(sidebarViewModel)); }
public IHttpActionResult GetSidebar(int id) { SidebarDto sidebar = _sidebarService.GetById(id); if (sidebar == null) { return(NotFound()); } return(Ok(sidebar)); }
public ActionResult SidebarPartial() { SidebarVM model; using (DB db = new DB()) { SidebarDto dto = db.Sidebars.Find(1); model = new SidebarVM(dto); } return(PartialView(model)); }
public ActionResult EditSidebar(SidebarViewModel sidebarViewModel) { using (var db = new Db()) { SidebarDto dto = db.Sidebar.Find(1); dto.Body = sidebarViewModel.Body; db.SaveChanges(); } TempData["SM"] = "You have edited the sidebar!"; return(RedirectToAction("EditSidebar")); }
public ActionResult EditSidebar(SidebarVm model) { SidebarDto dto = db.Sidebars.Find(1); dto.Body = model.Body; db.SaveChanges(); TempData["SuccessMessage"] = "You have edited this page!"; return(RedirectToAction("EditSidebar")); }
public void Update(int id, SidebarDto sidebar) { using (var uow = new UnitOfWork()) { Sidebar sidebarDb = new Sidebar() { Id = sidebar.Id, Body = sidebar.Body }; uow.SidebarRepository.Update(sidebarDb); uow.SaveChanges(); } }
public SidebarDto GetById(int id) { using (var uow = new UnitOfWork()) { var getSidebar = uow.SidebarRepository.GetById(id); SidebarDto sidebar = new SidebarDto() { Id = getSidebar.Id, Body = getSidebar.Body }; return(sidebar); } }
public ActionResult EditSidebar(SidebarVM model) { using (DB db = new DB()) { SidebarDto dto = db.Sidebars.Find(1); dto.Body = model.Body; db.SaveChanges(); } TempData["SM"] = "Sidebar successfully edited."; return(RedirectToAction("EditSidebar")); }
public void Add(SidebarDto page) { using (var uow = new UnitOfWork()) { Sidebar sidebarDb = new Sidebar() { Id = page.Id, Body = page.Body }; uow.SidebarRepository.Insert(sidebarDb); uow.SaveChanges(); //return ; } }
public ActionResult EditSidebar() { //Declare model SidebarVM model; using (Db db = new Db()) { //Get the DTO SidebarDto dto = db.Sidebar.Find(1); //Initialize the model model = new SidebarVM(dto); } //Return view with the model return(View(model)); }
public ActionResult EditSidebar(SidebarVM model) { using (Db db = new Db()) { //Get the DTO SidebarDto dto = db.Sidebar.Find(1); //DTO the body dto.Body = model.Body; //Save db.SaveChanges(); } //Set the TempData TempData["SM"] = "You have edited the sidebar!"; //Redirect return(RedirectToAction("EditSidebar")); }
public SidebarViewModel(SidebarDto sidebarDto) { Id = sidebarDto.Id; Body = sidebarDto.Body; }
public SidebarVM(SidebarDto row) { Id = row.Id; Body = row.Body; }
public bool SaveSidebar(SidebarDto sidebarDto) { //_db.Sidebar.Add(sidebarDto); _db.Entry(sidebarDto).State = EntityState.Modified; return(_db.SaveChanges() > 0); }
public SidebarViewModel(SidebarDto dto) { Id = dto.Id; Body = dto.Body; }