public void CreateSuggestion_Success(string email, string name, string content) { var suggestion = new Suggestion { Content = content, Name = name, Email = email }; var repositoryMock = new Mock <ISuggestRepository>(); repositoryMock.Setup(x => x.CreateSuggetion(It.IsAny <Suggestion>())) .Returns(suggestion); var suggestService = new SuggestService(repositoryMock.Object); var result = suggestService.CreateSuggestion(name, email, content); Assert.IsType <CreateSuggestionReturnModel>(result); Assert.IsType <Suggestion>(result.CreatedSuggestion); Assert.True(result.IsSuccessful); Assert.Equal(name, result.CreatedSuggestion.Name); Assert.Equal(email, result.CreatedSuggestion.Email); Assert.Equal(content, result.CreatedSuggestion.Content); }
protected void Page_Load(object sender, EventArgs e) { //if (string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name)) //{ // FormsAuthentication.RedirectToLoginPage(); // return; //} SuggestService service = new SuggestService(); _suggestCount = service.GetSuggestCount(); if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["pageIndex"])) { this._currentPageIndex = Convert.ToInt32(Request.QueryString["pageIndex"]); } } if (!string.IsNullOrEmpty(Request.QueryString["id"])) { Guid id = new Guid(Request.QueryString["id"]); try { service.RemoveSuggest(id); Response.Write("<script language=javascript>alert('删除成功');</script>"); } catch { } } }
public string AddSuggest(int category, string content, string method) { string userName = "******"; string userAccount = string.Empty; if (HttpContext.Current.Session[BasePage.EmployeeSessionKey] != null) { var CurrentUser = HttpContext.Current.Session[BasePage.EmployeeSessionKey] as DataTransferObject.Organization.EmployeeDetailInfo; userName = CurrentUser.Name; userAccount = CurrentUser.UserName; } var suggest = new Suggest { SuggestCategory = (SuggestCategory)category, SuggestContent = HtmlFilter.Replace(content, string.Empty), ContractInformation = HtmlFilter.Replace(method, string.Empty), CreateTime = DateTime.Now, Creator = userAccount, CreatorName = userName, Id = Guid.NewGuid(), Readed = false, Handled = false }; SuggestService.AddSuggest(suggest); return("OK"); }
/// <summary> /// 用于注册各类的ViewModelLocator /// </summary> public static void RunAllConfig() { if (AllConfig == null) { return; } SimpleIoc.Default.Register <HomePage_Model>(); SimpleIoc.Default.Register <AboutPage_Model>(); SimpleIoc.Default.Register <SearchPage_Model>(); SimpleIoc.Default.Register <AddFriendPage_Model>(); SimpleIoc.Default.Register <ShowFriendPage_Model>(); SimpleIoc.Default.Register <IDbContentService, DbContext>(); SimpleIoc.Default.Register <IDataService, DataService>(); SimpleIoc.Default.Register <ISuggestService, SuggestService>(); SimpleIoc.Default.Register <IFileService, FileService>(); SimpleIoc.Default.Register <IImageService, ImageService>(); Services.ServiceLocator.Instance.Register <DbContext>(DbContext.GetInstance()); Services.ServiceLocator.Instance.Register <DataService>(DataService.GetInstance()); Services.ServiceLocator.Instance.Register <SuggestService>(SuggestService.GetInstance()); Services.ServiceLocator.Instance.Register <FileService>(FileService.GetInstance()); Services.ServiceLocator.Instance.Register <ImageService>(ImageService.GetInstance()); foreach (var item in AllConfig) { item(); } }
public void CreateSuggestion_ParamError(string email, string name, string content) { var repositoryMock = new Mock <ISuggestRepository>(); repositoryMock.Setup(x => x.CreateSuggetion(It.IsAny <Suggestion>())) .Returns(new Suggestion()); var suggestService = new SuggestService(repositoryMock.Object); var result = suggestService.CreateSuggestion(name, email, content); Assert.IsType <CreateSuggestionReturnModel>(result); Assert.False(result.IsSuccessful); Assert.Equal(ReturnErrorType.InvalidParameters, result.ErrorType); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Form["txtContent"]) && !string.IsNullOrEmpty(Request.Form["sid"])) { SuggestService service = new SuggestService(); SuggestModel model = new SuggestModel(); model.SuggestID = new Guid(Request.Form["sid"]); model.Reply = Request.Form["txtContent"]; try { service.ReplySuggest(model); Response.Redirect("SuggestList.aspx"); } catch { } } }
private void queryCompanys(Pagination pagination) { try { var suggests = SuggestService.GetSuggest(string.IsNullOrWhiteSpace(txtAppliedDateStart.Text) ? (DateTime?)null : DateTime.Parse(txtAppliedDateStart.Text), string.IsNullOrWhiteSpace(txtAppliedDateEnd.Text) ? (DateTime?)null : DateTime.Parse(txtAppliedDateEnd.Text).AddDays(1).AddSeconds(-1), ddlSuggestType.SelectedValue == string.Empty ? null : (SuggestCategory?)int.Parse(ddlSuggestType.SelectedValue) , pagination); datalist.DataSource = suggests.Select(s => new { SuggestCategory = s.SuggestCategory.GetDescription(), s.SuggestContent, CreateTime = s.CreateTime.ToString(DateFromat), s.CreatorName, s.Creator, s.ContractInformation, Employee = s.EmployeeId.HasValue ? "<a href='./EmployeeInfo.aspx?employeeId=" + s.EmployeeId.Value + "' >" + s.CreatorName + "</a>" : s.CreatorName }); datalist.DataBind(); if (pagination.RowCount > 0) { pager.Visible = true; if (pagination.GetRowCount) { pager.RowCount = pagination.RowCount; } } else { pager.Visible = false; } } catch (Exception ex) { ShowExceptionMessage(ex, "查询"); } }
public SuggestListModel(SuggestService suggestService) { _suggestService = suggestService; }
public SuggestModel(SuggestService suggestModel) { _suggestService = suggestModel; }
static NewFactory() { _suggestService = new SuggestService(); }
public SingleModel(IUserService service, SuggestService suggestService) : base(service) { _service = service; _suggestService = suggestService; }
public PublishSuggestModel(SuggestService suggestService, IUserService service) : base(service) { _suggestService = suggestService; _service = service; }
public SuggestController(SuggestService suggest) { _suggest = suggest; }
public MySuggestModel(SuggestService suggestService) { _suggestService = suggestService; }
public SuggestSingleModel(SuggestService suggestService, UserService userService) { _suggestService = suggestService; _userService = userService; }