Пример #1
0
        public ActionResult AddOrUpdate(Branch branch)
        {
            try
            {
                try
                {
                    string logoName   = Path.GetFileName(branch.file.FileName);
                    var    folderPath = Server.MapPath("~/images/branches");
                    if (!Directory.Exists(folderPath))
                    {
                        Directory.CreateDirectory(folderPath);
                    }
                    string path = Path.Combine(folderPath, logoName);
                    branch.file.SaveAs(path);
                    branch.Logo = "images/branches/" + logoName;
                }
                catch (System.Exception)
                {
                }

                _branchService.AddOrUpdate(branch);
                var responseModel = new ResponseModel
                {
                    StatusCode = (int)HttpStatusCode.OK,
                    MessageAr  = branch.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));
            }
        }