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);
        }
Пример #2
0
        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
                { }
            }
        }
Пример #3
0
        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");
        }
Пример #4
0
        /// <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);
        }
Пример #6
0
        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
                { }
            }
        }
Пример #7
0
 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, "查询");
     }
 }
Пример #8
0
 public SuggestListModel(SuggestService suggestService)
 {
     _suggestService = suggestService;
 }
Пример #9
0
 public SuggestModel(SuggestService suggestModel)
 {
     _suggestService = suggestModel;
 }
Пример #10
0
 static NewFactory()
 {
     _suggestService = new SuggestService();
 }
Пример #11
0
 public SingleModel(IUserService service, SuggestService suggestService) : base(service)
 {
     _service        = service;
     _suggestService = suggestService;
 }
 public PublishSuggestModel(SuggestService suggestService, IUserService service) : base(service)
 {
     _suggestService = suggestService;
     _service        = service;
 }
Пример #13
0
 public SuggestController(SuggestService suggest)
 {
     _suggest = suggest;
 }
Пример #14
0
 public MySuggestModel(SuggestService suggestService)
 {
     _suggestService = suggestService;
 }
Пример #15
0
 public SuggestSingleModel(SuggestService suggestService, UserService userService)
 {
     _suggestService = suggestService;
     _userService    = userService;
 }