public ActionResult AddOrUpdate(Item item) { try { var logoName = Path.GetFileName(item.file.FileName); var folderPath = Server.MapPath("~/images/items"); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } var path = Path.Combine(folderPath, logoName); item.file.SaveAs(path); item.Picture = "images/items/" + logoName; } catch (System.Exception) { } try { itemService.AddOrUpdate(item); var responseModel = new ResponseModel { StatusCode = (int)HttpStatusCode.OK, MessageAr = item.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)); } }