public ActionResult Delete(long id) { Authoring.DeleteAuthor(id); Caching.RemoveAuthor(id); return(Json(id)); }
public ActionResult Update(Models.Author author) { Data.Author persistentAuthor = Mapper.Map <Models.Author, Data.Author>(author); Authoring.UpdateAuthor(persistentAuthor); Caching.UpdateAuthor(persistentAuthor); return(Content(JsonConvert.SerializeObject(Mapper.Map <Data.Author, Models.Author>(persistentAuthor)))); }
public ActionResult Create(Authoring.WebRole.Models.Permission permission) { if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, admin)) return RedirectToAction("Index", "Home"); if (ModelState.IsValid) { permission.ID = Guid.NewGuid(); permission.CreatedBy = Guid.Parse(Session["userid"].ToString()); permission.CreatedOn = DateTime.Now; db.Permissions.AddObject(permission); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", permission.CreatedBy); ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", permission.ModifiedBy); return View(permission); }
public void LogOff() { var request = new RestRequest("api/v1/logout", Method.GET) { RequestFormat = DataFormat.Json }; request.AddHeader("X-Auth-Token", Authoring.AuthToken); request.AddHeader("X-User-Id", Authoring.UserId); var response = Client.Execute(request); if (!response.IsSuccessful) { throw new Exception("Response is not successful"); } Authoring = null; }
public void Logon(string username, string password) { var request = new RestRequest("api/v1/login", Method.POST) { RequestFormat = DataFormat.Json }; var json = $"{{ \"user\" : \"{username}\", \"password\" : \"{password}\" }}"; request.AddParameter("application/json", json, ParameterType.RequestBody); var response = Client.Execute <RequestResult <Authoring> >(request); if (!response.IsSuccessful) { throw new Exception("Response is not successful"); } Authoring = response.Data.Data; }
public ActionResult ByID(long id) { return(Content(JsonConvert.SerializeObject(Mapper.Map <Models.Author>(Authoring.GetAuthorByID(id))))); }
// GET: Author public ActionResult Index() { return(View(new Models.ModelWithController <IEnumerable <Models.Author> > { ClientController = "author-ctrl", Contents = Mapper.Map <IEnumerable <Data.Author>, IEnumerable <Models.Author> >(Authoring.GetAllAuthors()) })); }
private static Dictionary <long, string> GenerateCachedAuthors() { return(Authoring.GetAllAuthors().ToDictionary(a => a.ID, a => a.ToString())); }