Ejemplo n.º 1
0
        public JsonResult submitEditNotes(string title, string content, int noteID, int SortID, string imgUrl, int AdFlag = 0, int DepTrainFlag = 0, int type = 0, string deleteID = "", int publish = 0)
        {
            try
            {
                var model = new Sys_Notes()
                {
                    NoteTitle    = title,
                    NoteContent  = content,
                    UserId       = CurrentUser.UserId,
                    publishflag  = 0,
                    IsDelete     = 0,
                    NoteId       = noteID,
                    SortID       = SortID,
                    Type         = type,
                    AdFlag       = AdFlag,
                    DepTrainFlag = DepTrainFlag,
                    TenantId     = CurrentTenant.TenantId,
                    publishtime  = null,
                    CreateTime   = DateTime.Now
                };
                if (publish == 1)
                {
                    model.publishtime = DateTime.Now;
                    model.publishflag = 1;
                }
                if (Request.Files.Count > 0)
                {
                    model.ImageUrl = SaveFile(Request.Files[0]);
                }
                else if (!string.IsNullOrEmpty(imgUrl))
                {
                    model.ImageUrl = imgUrl;
                }

                if (noteID > 0)
                {
                    _notesManager.UpdateNotes(model);

                    //删除附件
                    if (deleteID != "")
                    {
                        _notesManager.DeleteNotesResource(deleteID.GetArray());
                    }
                }
                else
                {
                    _notesManager.AddNotes(model);
                }
                return(Json(new
                {
                    result = 1,
                    Id = model.NoteId,
                    content = RetechWing.LanguageResources.Common.SaveSuccess + RetechWing.LanguageResources.Common.ExclamationMark
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new
                {
                    result = 0,
                    content = RetechWing.LanguageResources.Common.SaveFailed + RetechWing.LanguageResources.Common.ExclamationMark
                }, JsonRequestBehavior.AllowGet));
            }
        }