Beispiel #1
0
        public ActionResult Delete(long id)
        {
            Authoring.DeleteAuthor(id);

            Caching.RemoveAuthor(id);

            return(Json(id));
        }
Beispiel #2
0
        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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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;
        }
Beispiel #6
0
 public ActionResult ByID(long id)
 {
     return(Content(JsonConvert.SerializeObject(Mapper.Map <Models.Author>(Authoring.GetAuthorByID(id)))));
 }
Beispiel #7
0
 // 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())
     }));
 }
Beispiel #8
0
 private static Dictionary <long, string> GenerateCachedAuthors()
 {
     return(Authoring.GetAllAuthors().ToDictionary(a => a.ID, a => a.ToString()));
 }