public ActionResult EditAgent(long id)
 {
     try
     {
         ViewBag.ActiveURL = "/Admin/agentlist";
         SaveAgent model = new SaveAgent();
         model.Agent = objAPI.GetObjectByKey <utblAgent>("AgentConfig", "agentbyid", id.ToString(), "agentID");
         return(View(model));
     }
     catch (AuthorizationException)
     {
         TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again";
         return(RedirectToAction("Login", "Account", new { Area = "" }));
     }
 }
        public ActionResult AddAgent(SaveAgent model)
        {
            try
            {
                ViewBag.ActiveURL = "/Admin/Agentlist";

                if (!(model.cropper.PhotoNormal == null || model.cropper.PhotoNormal == ""))
                {
                    Random rand          = new Random();
                    string name          = model.Agent.AgentName + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(50) + ".jpg";
                    bool   isValidFile   = FileTypeCheck.DataImage(model.cropper.PhotoNormal);
                    string normal_result = SaveImage(model.cropper.PhotoNormal, name);
                    if (normal_result.Contains("Error"))
                    {
                        TempData["ErrMsg"] = normal_result;
                        return(RedirectToAction("BannerList", "Banner"));
                    }
                    else
                    {
                        model.Agent.AgentDocumentPath = FileUrl + "/AgentDocument/" + normal_result;
                    }
                }

                if (ModelState.IsValid)
                {
                    string jsonStr = JsonConvert.SerializeObject(model.Agent);
                    TempData["ErrMsg"] = objAPI.PostRecordtoApI("AgentConfig", "saveagent", jsonStr);
                    return(RedirectToAction("AgentList", "AgentConfig", new { Area = "Admin" }));
                }
                return(View(model));
            }
            catch (AuthorizationException)
            {
                TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again";
                return(RedirectToAction("Login", "Account", new { Area = "" }));
            }
        }