protected void btnSave_Click(object sender, EventArgs e) { if (this.selectCategory.SelectedItem == null || this.txtTitle.Text.Trim() == string.Empty) { return; } NewBlogStoryModel m = new NewBlogStoryModel(); m.Title = this.txtTitle.Text.Trim(); m.Body = Request.Form["editorcontent"]; m.CategoryID = new Guid(this.selectCategory.SelectedValue); m.CategoryName = this.selectCategory.SelectedItem.Text; //从cookie获取用户名及用户的ID HttpCookie hc = Request.Cookies[FormsAuthentication.FormsCookieName]; FormsAuthenticationTicket fat = FormsAuthentication.Decrypt(hc.Value); m.AccountID = new Guid(fat.Name); m.UserName = fat.UserData; try { srv.CreateBlogStory(m); } catch (Exception error) { } }
public void InitializeOperands() { service = new BlogService(); model = new NewBlogStoryModel(); model.AccountID = new Guid("a8074051-1818-4fd6-88cc-0d8e18fd3d7e"); model.Body = ""; model.CategoryID = new Guid("62fe6c96-c5ce-46d1-9bb7-ab076046c428"); model.CategoryName = "看我发明"; model.ImgName = "123"; model.IsPublishedToHomepage = true; model.IsRequireDigest = true; IList <String> k = new List <String>(); k.Add("123"); model.Tags = k; model.Title = "12"; model.UserName = "******"; model.UserTiny = "123"; }