Exemplo n.º 1
0
        public JsonResult SaveUploadJS(ExtractViewModel extract)
        {
            var ajaxResponse = new AjaxResponse {
                Success = false, Message = "An error occurred while saving the upload."
            };

            //should have already been caught by client, but check again
            if (!ModelState.IsValid)
            {
                ajaxResponse.Message = "Please complete all required form fields.";
                return(Json(ajaxResponse));
            }

            try
            {
                extract.TheUnitOfWork = _unitOfWork;

                if (!extract.IsUniqueYN())   //Uniqueness of extract
                {
                    ajaxResponse.Message = "The upload name already exists.";
                    return(Json(ajaxResponse));
                }

                int id = extract.UpdateAndSave();

                ajaxResponse.Message = "Success";
                ajaxResponse.Success = true;
            }
            catch (Exception ex)
            {
                ErrorTools.HandleError(ex, ErrorLevel.NonFatal);    //just log, no redirect
            }

            return(Json(ajaxResponse));
        }
Exemplo n.º 2
0
        public JsonResult SaveUploadJS(ExtractViewModel extract)
        {
            var ajaxResponse = new AjaxResponse { Success = false, Message = "An error occurred while saving the upload." };

            //should have already been caught by client, but check again
            if (!ModelState.IsValid)
            {
                ajaxResponse.Message = "Please complete all required form fields.";
                return Json(ajaxResponse);
            }

            try
            {
                extract.TheUnitOfWork = _unitOfWork;

                if (!extract.IsUniqueYN())   //Uniqueness of extract
                {
                    ajaxResponse.Message = "The upload name already exists.";
                    return Json(ajaxResponse);
                }

                int id = extract.UpdateAndSave();

                ajaxResponse.Message = "Success";
                ajaxResponse.Success = true;
            }
            catch (Exception ex)
            {
                ErrorTools.HandleError(ex, ErrorLevel.NonFatal);    //just log, no redirect
            }

            return Json(ajaxResponse);
        }