Beispiel #1
0
 public ActionResult Add()
 {
     try
     {
         DestinationSaveModel model = new DestinationSaveModel();
         model.CountryList = objAPI.GetAllRecords <CountryDD>("configuration", "CountriesList");
         return(View(model));
     }
     catch (AuthorizationException)
     {
         TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again";
         return(RedirectToAction("Login", "Account", new { Area = "" }));
     }
 }
 public ActionResult Edit(long id)
 {
     try
     {
         DestinationSaveModel model = new DestinationSaveModel();
         model.Destination = objAPI.GetObjectByKey <utblMstDestination>("configuration", "destinationbyid", id.ToString(), "id");
         model.CountryList = objAPI.GetAllRecords <CountryDD>("configuration", "CountriesList");
         return(View(model));
     }
     catch (AuthorizationException)
     {
         TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again";
         return(RedirectToAction("Login", "Account", new { Area = "" }));
     }
 }
Beispiel #3
0
 public ActionResult Edit(DestinationSaveModel model)
 {
     try
     {
         if (model.cropper.PhotoNormal != null)
         {
             bool isValidFile = FileTypeCheck.DataImage(model.cropper.PhotoNormal);
             //bool isValidThumb = FileTypeCheck.DataImage(model.cropper.PhotoThumb);
             if (!isValidFile)
             {
                 TempData["ErrMsg"] = "Please Select A Valid Image File!";
                 return(View());
             }
             Random rand          = new Random();
             string name          = "Banner_" + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(50) + ".webp";
             string normal_result = SaveImage(model.cropper.PhotoNormal, name);
             if (normal_result.Contains("Error"))
             {
                 TempData["ErrMsg"] = "Please Select A Valid Image File!";
                 return(View());
             }
             else
             {
                 model.Destination.DestinationImagePath = "/Uploads/Destinations/" + normal_result;
             }
         }
         else
         {
             model.Destination.DestinationImagePath = model.Destination.DestinationImagePath;
         }
         if (ModelState.IsValid)
         {
             string jsonStr = JsonConvert.SerializeObject(model.Destination);
             TempData["ErrMsg"] = objAPI.PostRecordtoApI("configuration", "savedestination", jsonStr);
             return(RedirectToAction("index", "destination", new { Area = "Admin" }));
         }
         model.CountryList = objAPI.GetAllRecords <CountryDD>("configuration", "CountriesList");
         return(View(model));
     }
     catch (AuthorizationException)
     {
         TempData["ErrMsg"] = "Your Login Session has expired. Please Login Again";
         return(RedirectToAction("Login", "Account", new { Area = "" }));
     }
 }