예제 #1
0
        public ActionResult UploadPortrait(string portrait)
        {
            var apiResult = new APIResult();

            if (string.IsNullOrWhiteSpace(portrait))
            {
                apiResult.Ret = -1;
                apiResult.Msg = "头像数据为空";
                return(Json(apiResult));
            }
            try
            {
                //上传头像
                portrait = BitmapFormate.ImgSave("user", portrait);
                if (portrait != string.Empty)
                {
                    UserBll.ChangePortrait(UserContext.CurrentUser.Id, portrait);
                }
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }

            return(Json(apiResult));
        }