// GET: Admin/Category public ActionResult AddCategory(Guid?id) { try { var objects = new Dictionary <string, dynamic>(); var categories = ApiUtil.GetCategoryListForAdmin().Result; objects.Add("Categories", categories); ViewBag.Data = objects; if (id == null) { return(View(new Category())); } else { var category = ApiUtil.GetCategory(id.Value); return(View(category.Result)); } } catch (System.Exception ex) { return(RedirectToAction("Index", new RouteValueDictionary(new { controller = "ErrorHandler", action = "Index", data = ex.InnerException?.Message ?? ex.Message }))); } }