Beispiel #1
0
 public ActionResult AddOrUpdate(Vendor vendor)
 {
     try
     {
         var logoName   = Path.GetFileName(vendor.file.FileName);
         var folderPath = Server.MapPath("~/images/vendors");
         if (!Directory.Exists(folderPath))
         {
             Directory.CreateDirectory(folderPath);
         }
         var path = Path.Combine(folderPath, logoName);
         vendor.file.SaveAs(path);
         vendor.Photo = "images/vendors/" + logoName;
     }
     catch (System.Exception)
     {
     }
     try
     {
         vendorService.AddOrUpdate(vendor);
         var responseModel = new ResponseModel
         {
             StatusCode = (int)HttpStatusCode.OK,
             MessageAr  = vendor.Id > 0 ? AppResource.UpdatedSuccessfully : AppResource.SavedSuccessfully
         };
         return(Json(responseModel, JsonRequestBehavior.AllowGet));
     }
     catch (System.Exception)
     {
         var responseModel = new ResponseModel
         {
             StatusCode = (int)HttpStatusCode.InternalServerError,
             MessageAr  = AppResource.ChangesNotSaved
         };
         return(Json(responseModel, JsonRequestBehavior.AllowGet));
     }
 }