コード例 #1
0
 public CommentItemComponentModel(PersonView loginPerson, CommentView commentView, DbFactory dbFactory, bool isLike)
 {
     LoginPerson    = loginPerson;
     CommentView    = commentView;
     this.dbFactory = dbFactory;
     this.IsLike    = isLike;
 }
コード例 #2
0
        void ReleaseDesignerOutlets()
        {
            if (VerifyButton != null)
            {
                VerifyButton.Dispose();
                VerifyButton = null;
            }

            if (ChooseButton2 != null)
            {
                ChooseButton2.Dispose();
                ChooseButton2 = null;
            }

            if (PersonView != null)
            {
                PersonView.Dispose();
                PersonView = null;
            }

            if (PersonNameLabel != null)
            {
                PersonNameLabel.Dispose();
                PersonNameLabel = null;
            }

            if (PersonImageView != null)
            {
                PersonImageView.Dispose();
                PersonImageView = null;
            }
        }
コード例 #3
0
        protected void RulesValidationUsers(PersonView vm, Owner owner)
        {
            //if (string.IsNullOrEmpty((vm.Rnc)) == false)
            //{
            //    var emp = Context.People.Any(p => p.User.Rnc.ToUpper() == vm.Rnc.ToUpper()
            //                                      && p.CreatedUser.Owner == owner);

            //    if (emp)
            //    {
            //        ModelState.AddModelError(string.Empty, "Esta cedula ya esta registrada");
            //        // return View(vm);
            //    }
            //}

            if (string.IsNullOrEmpty((vm.Email)))
            {
                ModelState.AddModelError(string.Empty, "El Email es Obligatorio");
            }

            if (string.IsNullOrEmpty(vm.Email) == false)
            {
                var emp = Context.Users.Any(p => p.Email.ToUpper() == vm.Email.ToUpper() &&
                                            p.Owner == owner);

                if (emp)
                {
                    ModelState.AddModelError(string.Empty, "Este Email ya esta registrado");
                    // return View(vm);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// 指定の物を追加する
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async Task <PersonView> Post(PersonView person)
        {
            //最新IDにする
            person.id = maxId();

            var js = new Newtonsoft.Json.JsonSerializer();
            var sw = new System.IO.StringWriter();

            js.Serialize(sw, person);
            var hc = new HttpClient();

            hc.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var json = sw.ToString();
            var cont = new StringContent(json, Encoding.UTF8, "application/json");
            var res  = await hc.PostAsync(common.GetURL() + "people", cont);

            var str = await res.Content.ReadAsStringAsync();

            testMess.Text = str;

            var jr   = new Newtonsoft.Json.JsonTextReader(new System.IO.StringReader(str));
            var item = js.Deserialize <PersonView>(jr);

            return(item);
        }
コード例 #5
0
ファイル: InviteController.cs プロジェクト: weedkiller/GAsk
        public async Task <IActionResult> Create(InviteEditModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    PersonView person = await this.personService.GetCurrentPersonViewAsync();

                    InviteCode code = await this.inviteService.InsertAsync(model, person);

                    return(this.Json(AjaxResult.CreateByContext(code)));
                }
                catch (ModelException ex)
                {
                    return(this.Json(ex.ToAjaxResult()));
                }
                catch (Exception ex)
                {
                    return(this.Json(AjaxResult.CreateByMessage(ex.Message, false)));
                }
            }
            else
            {
                return(this.Json(ModelState.ToAjaxResult()));
            }
        }
コード例 #6
0
ファイル: PostService.cs プロジェクト: weedkiller/GAsk
 /// <summary>
 /// 获取最新推荐的提问
 /// </summary>
 public async Task <List <PostView> > GetNewBestQuestionAsync(PersonView person)
 {
     using (var work = this.dbFactory.StartWork())
     {
         return(await work.PostView.GetNewBestQuestionAsync(person));
     }
 }
コード例 #7
0
ファイル: ProfileController.cs プロジェクト: weedkiller/GAsk
        public async Task <IActionResult> ModifyAvatar()
        {
            PersonView person = await this.personService.GetCurrentPersonViewAsync();

            this.ViewData["avatar"] = person.Avatar;
            return(View());
        }
コード例 #8
0
        void PersonView_Loaded(object sender, RoutedEventArgs e)
        {
            PersonView personView = (PersonView)sender;

            manager.Bars["mainBar"].UnMerge();
            manager.Bars["mainBar"].Merge(personView.ChildBar);
        }
コード例 #9
0
        /// <summary>
        /// 插入邀请码
        /// </summary>
        public async Task <InviteCode> InsertAsync(InviteEditModel model, PersonView person)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (person == null)
            {
                throw new ArgumentNullException(nameof(person));
            }
            using (var work = this.dbFactory.StartWork())
            {
                if (await work.InviteCode.IsExistCodeAsync(model.Code))
                {
                    throw new ModelException(nameof(model.Code), "该邀请码已存在");
                }
                else
                {
                    InviteCode code = new InviteCode {
                        Code = model.Code, Id = GuidHelper.CreateSequential(), PersonId = person.Id
                    };
                    await work.InviteCode.InsertAsync(code);

                    return(code);
                }
            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            PersonView pv = new PersonView();

            pv.Input();
            pv.Display();
        }
コード例 #11
0
ファイル: PersonController.cs プロジェクト: omn4ma/Payroll
        public int SavePerson(PersonView person)
        {
            var model = mapper.Map <Person>(person);
            var id    = repository.Save(model);

            return(id);
        }
コード例 #12
0
        public ActionResult Create()
        {
            var personView = new PersonView(db, Operator().OwnerGroupId);

            //personView.FamilyList = new SelectList(db.Families, "Id", "Name", personView.SelectedFamilyId).ToList();
            return(View(personView));
        }
コード例 #13
0
        public void IsValidTest_ReadOnly()
        {
            var view      = new PersonView();
            var viewModel = new PersonViewModel(view);

            ValidationHelper.SetIsValid(view, true);
        }
コード例 #14
0
        /// <summary>
        /// 修改用户密码
        /// </summary>
        public async Task ModifyPasswordAsync(ProfileModifyPasswordModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            string     pwdHash = this.encryptService.PasswordHash(model.NewPassword);
            PersonView person  = await this.GetCurrentPersonViewAsync();

            using (var work = this.dbFactory.StartWork())
            {
                if (person.Password != this.encryptService.PasswordHash(model.Password))
                {
                    throw new ModelException(nameof(model.Password), "登录密码错误");
                }
                using (var trans = work.BeginTransaction())
                {
                    try
                    {
                        await work.Person.ModifyPasswordAsync(person.Id, pwdHash, trans);

                        await work.Person.UpdateLastTimeAsync(person.Id, trans);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }
        }
コード例 #15
0
        public async Task <IViewComponentResult> InvokeAsync(Post pPost)
        {
            if (pPost == null)
            {
                throw new ArgumentNullException(nameof(pPost));
            }
            PersonView loginUser = await this.personService.GetCurrentPersonViewAsync();

            PersonView publicUser = await this.personService.GetPersonViewAsync(pPost.PersonId);

            List <Tag> tags = await this.tagService.GetTagsByPostId(pPost.Id);

            ArticleContentComponentModel model = new ArticleContentComponentModel()
            {
                LoginPerson    = loginUser,
                Post           = pPost,
                PublicPerson   = publicUser,
                Tags           = tags,
                Topic          = await topicService.GetByIdAsync(pPost.TopicId),
                PostData       = await postService.GetPostDataAsync(pPost),
                IsLikePost     = await this.zanService.IsPostZanAsync(pPost.Id),
                CurrentUrl     = this.HttpContext.Request.Path,
                IsFavoritePost = await this.favoriteService.IsFavorite(pPost.Id)
            };

            return(View(model));
        }
コード例 #16
0
ファイル: Bootstrapper.cs プロジェクト: kouweizhong/Journeys
        public void BootstrapQueries(
            IQueryHandlerRegistry queryHandlerRegistry,
            IEventBus eventBus,
            IQueryDispatcher queryDispatcher)
        {
            var personView = new PersonView();

            queryHandlerRegistry.SetHandler <GetPersonIdByNameQuery, object>(personView.Execute);
            queryHandlerRegistry.SetHandler <GetPeopleNamesQuery, IEnumerable <PersonName> >(personView.Execute);
            eventBus.RegisterListener <PersonCreatedEvent>(personView.Update);

            var journeysByPassengerThenMonthThenDayView = new JourneysByPassengerThenMonthThenDayView();

            queryHandlerRegistry.SetHandler <GetJourneysByPassengerThenMonthThenDayQuery, IEnumerable <Fact> >(journeysByPassengerThenMonthThenDayView.Execute);
            eventBus.RegisterListener <JourneyCreatedEvent>(journeysByPassengerThenMonthThenDayView.Update);
            eventBus.RegisterListener <LiftAddedEvent>(journeysByPassengerThenMonthThenDayView.Update);

            var journeyView = new JourneyView();

            queryHandlerRegistry.SetHandler <GetJourneysInPeriodQuery, IEnumerable <Journey> >(journeyView.Execute);
            eventBus.RegisterListener <JourneyCreatedEvent>(journeyView.Update);
            eventBus.RegisterListener <LiftAddedEvent>(journeyView.Update);

            var passengerLiftsCostCalculator = new PassengerLiftCostCalculator(queryDispatcher);

            queryHandlerRegistry.SetHandler <GetCostOfPassengerLiftsInPeriodQuery, PassengerLiftsCost>(passengerLiftsCostCalculator.Execute);
        }
コード例 #17
0
        public async Task <IActionResult> BlockPost(Guid postId)
        {
            try
            {
                PersonView loginPerson = await this.personService.GetCurrentPersonViewAsync();

                Post post = await this.postService.GetPostByIdAsync(postId);

                if (post == null)
                {
                    throw new Exception("该帖子不存在");
                }
                bool isSelf  = loginPerson.Id == post.PersonId;
                bool isAdmin = loginPerson.RoleType == RoleType.Admin || loginPerson.RoleType == RoleType.Master || loginPerson.RoleType == RoleType.SuperAdmin;
                if (isSelf || isAdmin)
                {
                    await this.postService.BlockAsync(postId, loginPerson);

                    return(Json(AjaxResult.CreateDefaultSuccess()));
                }
                else
                {
                    throw new Exception("没有该操作的权限");
                }
            }
            catch (Exception ex)
            {
                return(Json(AjaxResult.CreateByMessage(ex.Message, false)));
            }
        }
コード例 #18
0
        internal void Find()
        {
            Person       foundPerson = null;
            StringDialog dialog      = new StringDialog("A partial last name");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string        lastName   = dialog.YourString;
                List <Person> candidates = _personRepository.ListByLastName(lastName);
                switch (candidates.Count)
                {
                case 0:
                    ReportIt("No person has last name " + lastName);
                    return;

                case 1:
                    foundPerson = candidates[0];
                    break;

                default:
                    foundPerson = ChooseAUniquePerson(candidates);
                    break;
                }
                PersonView view = new PersonView(this);
                view.Show();
            }
        }
コード例 #19
0
        private PersonView parseResultFromUrl(string res)
        {
            if (res != null)
            {
                var result = new JSONObject(res);

                string name      = result.GetString("nume");
                string email     = result.GetString("email");
                string birthdate = result.GetString("dataNastere");
                string gender    = result.GetString("sex");
                string avatar    = Utils.GetDefaults("Avatar");
                var    list      = new List <PersonalDisease>();

                JSONArray jsonList = result.GetJSONArray("afectiuni");
                for (var i = 0; i < jsonList.Length(); i++)
                {
                    var    jsonObj     = (JSONObject)jsonList.Get(i);
                    int    cod         = jsonObj.GetInt("id");
                    string nameDisease = jsonObj.GetString("denumire");

                    list.Add(new PersonalDisease(cod, nameDisease));
                }
                var obj = new PersonView(name, email, birthdate, gender, avatar, list, "none");
                return(obj);
            }
            return(null);
        }
コード例 #20
0
        private async Task <PersonView> CallServerToGetData()
        {
            Log.Error("ProfileActivity", "task started");
            PersonView person = null;
            await Task.Run(async() =>
            {
                try
                {
                    string res = await WebServices.WebServices.Get($"{Constants.PublicServerAddress}/api/myProfile", Utils.GetDefaults("Token"));
                    if (res != null)
                    {
                        Log.Error("ProfileActivity", res);
                        person = parseResultFromUrl(res);
                        if (person != null && person.ListOfPersonalDiseases != null)
                        {
                            await ProfileStorage.GetInstance().saveDiseases(person.ListOfPersonalDiseases);
                        }
                    }
                    else
                    {
                        Log.Error("ProfileActivity", "nu se poate conecta la server");
                    }
                }
                catch (Exception e)
                {
                    Log.Error("ProfileActivity Err", e.Message);
                }
            });

            return(person);
        }
コード例 #21
0
        private void Find(object sender, RoutedEventArgs e)
        {
            Person     p    = PersonToLookup();
            PersonView view = new PersonView(p);

            view.Show();
        }
コード例 #22
0
 public NavigationModel(MainWindow mainWindow)
 {
     _mainWindow   = mainWindow;
     _personWindow = new PersonWindow();
     _tableView    = new TableView();
     _personView   = new PersonView();
 }
コード例 #23
0
        /// <summary>
        /// 个人提问
        /// </summary>
        public async Task <IActionResult> Question(Guid id, int page = 1)
        {
            if (page < 1)
            {
                return(NotFound());
            }
            PersonView person = await this.personService.GetPersonViewAsync(id);

            if (person == null || person.IsDelete)
            {
                return(NotFound());
            }
            else
            {
                Person p = ObjectMapper.Map <PersonView, Person>(person);
                PagingResult <PostView> pagingResult = await this.postService.GetPagingResultAsync(person, Library.Enums.PostResultType.Question, page);

                if (pagingResult.PageCount > 1 && page > pagingResult.PageCount)
                {
                    return(NotFound());
                }
                UserQuestionViewModel model = new UserQuestionViewModel(pagingResult, person);
                return(View(model));
            }
        }
コード例 #24
0
        public void IsEnabledTest_CannotTurnOffAfterStart()
        {
            var view = new PersonView();

            ValidationHelper.SetIsEnabled(view, true);
            ValidationHelper.SetIsEnabled(view, false);
        }
コード例 #25
0
        private void OpenPersonView(object obj)
        {
            var             view = new PersonView();
            PersonViewModel vm   = new PersonViewModel(this);

            view.DataContext = vm;
            SelectedView     = view;
        }
コード例 #26
0
        public IActionResult Sort(string sortOrder)
        {
            PersonView pv = new PersonView();

            pv.persons = _personService.Sort(sortOrder);

            return(PartialView("_PersonList", pv));
        }
コード例 #27
0
ファイル: PostController.cs プロジェクト: weedkiller/GAsk
        public async Task <IActionResult> CreateAsk()
        {
            PersonView person = await this.personService.GetCurrentPersonViewAsync();

            PostEditModel model = await postService.CreateNewEditModelAsync(PostType.Question, person);

            return(View(model));
        }
コード例 #28
0
        public async Task <IActionResult> Create([FromBody] CommentEditModel model)
        {
            CommentView comment = await this.commentService.InsertAsync(model, this.User.GetUserId().Value);

            PersonView person = await this.personService.GetCurrentPersonViewAsync();

            return(ViewComponent(typeof(CommentItemViewComponent), new { pLoginPerson = person, pCommentView = comment }));
        }
コード例 #29
0
        public void IsValidTest_Binding_NotEnabled()
        {
            var view      = new PersonView();
            var viewModel = new PersonViewModel(view);

            Binding binding = new Binding("IsValid");

            BindingOperations.SetBinding(view, ValidationHelper.IsValidProperty, binding);
        }
コード例 #30
0
        public void IsEnabledTest()
        {
            var view = new PersonView();

            Assert.IsFalse(ValidationHelper.GetIsEnabled(view));

            ValidationHelper.SetIsEnabled(view, true);
            Assert.IsTrue(ValidationHelper.GetIsEnabled(view));
        }