Example #1
0
        protected void RadGridUser_PreRender(object sender, EventArgs e)
        {
            if (Request["me"] != null)
            {
                // select me
                LinqDataSourceUser.WhereParameters.Clear();
                LinqDataSourceUser.WhereParameters.Add("UserId", DbType.Int32, CurrentUserId.ToString());
                LinqDataSourceUser.Where = "UserId == @UserId";

                RadGridUser.MasterTableView.Rebind();

                foreach (GridDataItem item in RadGridUser.Items)
                {
                    if (item.GetDataKeyValue("UserId").ToString() == CurrentUserId.ToString())
                    {
                        item.Selected = true;
                        GetStaffInfo();
                        RadToolBarUser.FindItemByText("New").Enabled              = false;
                        RadToolBarUser.FindItemByText("Permission").Enabled       = false;
                        RadToolBarUser.FindItemByText("User Information").Enabled = false;
                        RadToolBarUser.FindItemByText("Update").Enabled           = true;
                        break;
                    }
                }
            }
        }
Example #2
0
        public async Task <IActionResult> AddPhotoForUser([FromForm] PhotoForCreationDto photoForCreationDto)
        {
            var file = photoForCreationDto.File;

            var uploadResult = new ImageUploadResult();

            if (file.Length > 0)
            {
                using (var stream = file.OpenReadStream())
                {
                    var uploadParams = new ImageUploadParams
                    {
                        File           = new FileDescription(file.Name, stream),
                        Transformation = new Transformation().Width(500).Height(500).Crop("fill").Gravity("face")
                    };

                    uploadResult = _cloudinary.Upload(uploadParams);
                }
            }

            photoForCreationDto.Url      = uploadResult.Url.ToString();
            photoForCreationDto.PublicId = uploadResult.PublicId;

            var photo = _mapper.Map <Photo>(photoForCreationDto);

            ApplicationUser currentUser = await _userManager.FindByIdAsync(CurrentUserId.ToString());

            currentUser.Photo = photo;
            await _userManager.UpdateAsync(currentUser);

            var photoToReturn = _mapper.Map <PhotoForReturnDto>(photo);


            return(CreatedAtRoute("GetPhoto", new { userId = CurrentUserId, id = photo.Id }, photoToReturn));
        }
Example #3
0
        protected void RadGridVacationSchema_OnBatchEditCommand(object sender, GridBatchEditingEventArgs e)
        {
            foreach (var command in e.Commands)
            {
                if (command.Type.ToString() != "Delete")
                {
                    var totalDays = (string.IsNullOrEmpty(Convert.ToString(command.NewValues["TotalDays"]))) ? 0 : Convert.ToDouble(command.NewValues["TotalDays"]);
                    var date      = (string.IsNullOrEmpty(Convert.ToString(command.NewValues["Date"]))) ? DateTime.Now : Convert.ToDateTime(command.NewValues["Date"]);

                    command.NewValues["UserId"] = Id;

                    command.NewValues["TotalDays"] = totalDays;
                    command.NewValues["Date"]      = date;

                    if (command.NewValues["VacationSchemaId"] == null)
                    {
                        command.NewValues["CreatedId"]   = CurrentUserId.ToString();
                        command.NewValues["CreatedDate"] = DateTime.Now;
                    }
                    else
                    {
                        command.NewValues["UpdatedId"]   = CurrentUserId.ToString();
                        command.NewValues["UpdatedDate"] = DateTime.Now;
                    }
                }
            }
        }
Example #4
0
        public async Task <IActionResult> Details(Guid id, int?pointsEarned, Guid notificationclicked)
        {
            notificationAppService.MarkAsRead(notificationclicked);

            OperationResultVo <GameViewModel> serviceResult = gameAppService.GetById(CurrentUserId, id);

            GameViewModel vm = serviceResult.Value;

            SetGameTeam(vm);

            SetTranslationPercentage(vm);

            SetImages(vm);

            bool isAdmin = false;

            if (!CurrentUserId.Equals(Guid.Empty))
            {
                ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString());

                bool userIsAdmin = await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString());

                isAdmin = user != null && userIsAdmin;
            }

            vm.Permissions.CanEdit         = vm.UserId == CurrentUserId || isAdmin;
            vm.Permissions.CanPostActivity = vm.UserId == CurrentUserId;

            SetGamificationMessage(pointsEarned);

            return(View(vm));
        }
Example #5
0
        public async Task <IActionResult> GetProfile()
        {
            var profile = _profileRepository.GetProfile(CurrentUserId);

            if (profile == null)
            {
                profile = new Profile.Profile
                {
                    UserId = CurrentUserId
                };
            }
            var user = await _userManager.FindByIdAsync(CurrentUserId.ToString());

            var logins = await _userManager.GetLoginsAsync(user);

            var hasPassword = await _userManager.HasPasswordAsync(user);

            var result = Mapper.Map <ProfileResponse>(profile);

            var measures = _measurementRepository.GetMeasures(CurrentUserId);

            result.Weight = measures.FirstOrDefault(m => m.Id == Constants.Measurements.WeightId)?.LatestValue;
            result.Height = measures.FirstOrDefault(m => m.Id == Constants.Measurements.HeightId)?.LatestValue;
            result.Rmr    = measures.FirstOrDefault(m => m.Id == Constants.Measurements.RmrId)?.LatestValue;

            result.Logins      = logins.Select(l => l.LoginProvider).ToArray();
            result.HasPassword = hasPassword;
            result.Username    = user.UserName;

            LogClientVersion();

            return(Ok(result));
        }
Example #6
0
        [HttpPost] //ValidateAntiForgeryToken
        public ActionResult Create(AdvertisementViewModel model)
        {
            if (TempData["NeedPayment"] != null)
            {
                TempData["NeedPayment"] = null;
            }

            if (!ModelState.IsValid)
            {
                PopulateDropDownListAndKeys(model);
                return(View(model));
            }
            if (!model.IsAdmin && !model.IsPaid)
            {
                TempData["NeedPayment"] = true;
                PopulateDropDownListAndKeys(model);
                return(View(model));
            }

            var ad = Mapper.Map <Advertisement>(model);

            ad.UserId         = CurrentUserId.ToString();
            ad.CreatedByAdmin = model.IsAdmin;
            _adsService.Create(ad);

            return(RedirectToAction(nameof(Index)));
        }
        public async Task<IViewComponentResult> InvokeAsync(int count, Guid? gameId, Guid? userId, Guid? oldestId, DateTime? oldestDate, bool? articlesOnly)
        {
            UserPreferencesViewModel preferences = _userPreferencesAppService.GetByUserId(CurrentUserId);

            ActivityFeedRequestViewModel vm = new ActivityFeedRequestViewModel
            {
                CurrentUserId = CurrentUserId,
                Count = count,
                GameId = gameId,
                UserId = userId,
                Languages = preferences.Languages,
                OldestId = oldestId,
                OldestDate = oldestDate,
                ArticlesOnly = articlesOnly
            };

            List<UserContentViewModel> model = _userContentAppService.GetActivityFeed(vm).ToList();

            ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString());
            bool userIsAdmin = user != null && await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString());

            foreach (UserContentViewModel item in model)
            {
                if (item.UserContentType == UserContentType.TeamCreation)
                {
                    FormatTeamCreationPost(item);
                }
                if (item.UserContentType == UserContentType.JobPosition)
                {
                    FormatJobPositionPostForTheFeed(item);
                }
                else
                {
                    item.Content = ContentHelper.FormatContentToShow(item.Content);
                }

                foreach (CommentViewModel comment in item.Comments)
                {
                    comment.Text = ContentHelper.FormatHashTagsToShow(comment.Text);
                }

                item.Permissions.CanEdit = !item.HasPoll && (item.UserId == CurrentUserId || userIsAdmin);

                item.Permissions.CanDelete = item.UserId == CurrentUserId || userIsAdmin;
            }

            if (model.Any())
            {
                UserContentViewModel oldest = model.OrderByDescending(x => x.CreateDate).Last();

                ViewData["OldestPostGuid"] = oldest.Id;
                ViewData["OldestPostDate"] = oldest.CreateDate.ToString("o");
            }

            ViewData["IsMorePosts"] = oldestId.HasValue;

            ViewData["UserId"] = userId;

            return await Task.Run(() => View(model));
        }
Example #8
0
        /// <include file='Docs/ExternalSummary.xml' path='docs/ShikiApi/method[@name="CreateAnimeRate"]/*' />
        public AnimeRate CreateAnimeRate(int title_id, UserStatus status = (UserStatus)99, int score = 0, int episodes = 0)
        {
            List <KeyValuePair <string, string> > keys = new List <KeyValuePair <string, string> >();

            //Обязательные
            keys.AddRange(new[]
            {
                new KeyValuePair <string, string>("user_rate[user_id]", CurrentUserId.ToString()),
                new KeyValuePair <string, string>("user_rate[target_id]", title_id.ToString()),
                new KeyValuePair <string, string>("user_rate[target_type]", "Anime"),
            });

            //Необязательные
            if ((int)status != 99)
            {
                keys.Add(new KeyValuePair <string, string>("user_rate[status]", status.ToString()));
            }
            if (score > 0)
            {
                keys.Add(new KeyValuePair <string, string>("user_rate[score]", score.ToString()));
            }
            if (episodes > 0)
            {
                keys.Add(new KeyValuePair <string, string>("user_rate[episodes]", episodes.ToString()));
            }

            var args = new FormUrlEncodedContent(keys);

            string url      = DomenApi + "v2/user_rates";
            var    response = Query.POST <_UserRate_v2>(url, args, this);

            return(new AnimeRate(response));
        }
Example #9
0
        protected void RadGridUserStatus_OnBatchEditCommand(object sender, GridBatchEditingEventArgs e)
        {
            foreach (var command in e.Commands)
            {
                if (command.Type.ToString() != "Delete")
                {
                    var date = (string.IsNullOrEmpty(Convert.ToString(command.NewValues["IssuedDate"]))) ? DateTime.Now : Convert.ToDateTime(command.NewValues["IssuedDate"]);

                    command.NewValues["UserId"] = Id;

                    command.NewValues["IssuedDate"] = date;

                    if (command.NewValues["UserStatusId"] == null)
                    {
                        command.NewValues["CreatedId"]   = CurrentUserId.ToString();
                        command.NewValues["CreatedDate"] = DateTime.Now;
                    }
                    else
                    {
                        command.NewValues["UpdatedId"]   = CurrentUserId.ToString();
                        command.NewValues["UpdatedDate"] = DateTime.Now;
                    }
                }
            }
        }
Example #10
0
        private async Task SetPermissions(GamificationLevelViewModel model)
        {
            ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString());

            bool userIsAdmin = await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString());

            model.Permissions.IsAdmin   = userIsAdmin;
            model.Permissions.CanDelete = model.Permissions.IsAdmin;
        }
Example #11
0
 public ActionResult Create()
 {
     PopulateDropDownListAndKeys();
     return(View(new AdvertisementViewModel
     {
         UserId = CurrentUserId.ToString(),
         CompanyId = CurrentUserCompanyId,
         IsAdmin = User.IsInRole(Constants.AdminRole)
     }));
 }
Example #12
0
 protected void RadGridGrade_OnBatchEditCommand(object sender, GridBatchEditingEventArgs e)
 {
     foreach (var command in e.Commands)
     {
         if (command.Type.ToString() != "Delete")
         {
             command.NewValues["UpdatedId"]   = CurrentUserId.ToString();
             command.NewValues["UpdatedDate"] = DateTime.Now;
         }
     }
 }
Example #13
0
 private void LoadDefualtInfo()
 {
     if (!IsUserAlreadyLogin)
     {
         CommonMethod.ResponseAjaxContent(this.Page, "notlogin");
     }
     else
     {
         CommonMethod.ResponseAjaxContent(this.Page, CurrentUserId.ToString() + ";" + Microsoft.JScript.GlobalObject.escape(CurrentUserName) + ";" + XiHuan_MessageFacade.GetNewMessageCount(CurrentUserId).ToString());
     }
 }
Example #14
0
        public IActionResult Detail(PregnancyViewModel model)
        {
            var SaveDetail = _patientService.SaveDetail(model, CurrentUserId.ToString());

            if (SaveDetail)
            {
                return(RedirectToAction("Index"));
            }

            model.IsAdmin = true;
            return(View(model));
        }
Example #15
0
        public async Task <IActionResult> Details(Guid id, Guid notificationclicked)
        {
            notificationAppService.MarkAsRead(notificationclicked);

            OperationResultVo <UserContentViewModel> serviceResult = userContentAppService.GetById(CurrentUserId, id);

            if (!serviceResult.Success)
            {
                TempData["Message"] = SharedLocalizer["Content not found!"].Value;
                return(RedirectToAction("Index", "Home"));
            }

            UserContentViewModel vm = serviceResult.Value;

            vm.Content = ContentHelper.FormatContentToShow(vm.Content);

            SetAuthorDetails(vm);

            if (vm.GameId.HasValue && vm.GameId.Value != Guid.Empty)
            {
                OperationResultVo <Application.ViewModels.Game.GameViewModel> gameServiceResult = gameAppService.GetById(CurrentUserId, vm.GameId.Value);

                Application.ViewModels.Game.GameViewModel game = gameServiceResult.Value;

                vm.GameTitle     = game.Title;
                vm.GameThumbnail = UrlFormatter.Image(game.UserId, ImageType.GameThumbnail, game.ThumbnailUrl);
            }

            vm.Content = vm.Content.Replace("image-style-align-right", "image-style-align-right float-right p-10");
            vm.Content = vm.Content.Replace("image-style-align-left", "image-style-align-left float-left p-10");
            vm.Content = vm.Content.Replace("<img src=", @"<img class=""img-fluid"" src=");

            if (string.IsNullOrEmpty(vm.Title))
            {
                vm.Title = SharedLocalizer["Content posted on"] + " " + vm.CreateDate.ToString();
            }

            if (string.IsNullOrWhiteSpace(vm.Introduction))
            {
                vm.Introduction = SharedLocalizer["Content posted on"] + " " + vm.CreateDate.ToShortDateString();
            }

            ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString());

            bool userIsAdmin = user != null && await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString());

            vm.Permissions.CanEdit   = vm.UserId == CurrentUserId || userIsAdmin;
            vm.Permissions.CanDelete = vm.UserId == CurrentUserId || userIsAdmin;

            ViewData["IsDetails"] = true;

            return(View(vm));
        }
Example #16
0
        public async Task <IActionResult> Create(PatientViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.PatientAdmin = CurrentUserId.ToString();
                var createUser = await _patientService.CreateUser(model);

                if (createUser)
                {
                    return(RedirectToAction("Index"));
                }
            }

            return(View());
        }
        public async Task <IActionResult> DeleteUser()
        {
            ApplicationUser user = await _userManager.FindByIdAsync(CurrentUserId.ToString());

            IdentityResult result = await _userManager.DeleteAsync(user);


            if (!result.Succeeded)
            {
                return(BadRequest(result.Errors.Select(e => e.Description).ToList()));
            }


            return(Ok());
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            // get completed or rejected list
            LinqDataSourceRequest.WhereParameters.Clear();
            LinqDataSourceRequest.WhereParameters.Add("Id", DbType.Int32, CurrentUserId.ToString());
            LinqDataSourceRequest.Where = "CreatedId == @Id";

            LinqDataSourceBusinessTripApproval.WhereParameters.Clear();
            LinqDataSourceBusinessTripApproval.WhereParameters.Add("ApprovalUser", DbType.Int32, CurrentUserId.ToString());
            LinqDataSourceBusinessTripApproval.WhereParameters.Add("IsApprovalRequest", DbType.Boolean, bool.TrueString);
            LinqDataSourceBusinessTripApproval.Where = "ApprovalUser == @ApprovalUser && IsApprovalRequest == @IsApprovalRequest && CreatedId != @ApprovalUser";
            //}
        }
        public async Task <IActionResult> Details(Guid id, Guid notificationclicked)
        {
            ProfileViewModel vm = profileAppService.GetByUserId(CurrentUserId, id, ProfileType.Personal);

            if (vm == null)
            {
                ProfileViewModel profile = profileAppService.GenerateNewOne(ProfileType.Personal);

                ApplicationUser user = await UserManager.FindByIdAsync(id.ToString());

                if (user != null)
                {
                    profile.UserId = id;
                    profileAppService.Save(CurrentUserId, profile);
                }
                else
                {
                    TempData["Message"] = SharedLocalizer["User not found!"].Value;
                    return(RedirectToAction("Index", "Home"));
                }

                vm = profile;
            }

            gamificationAppService.FillProfileGamificationDetails(CurrentUserId, ref vm);

            if (CurrentUserId != Guid.Empty)
            {
                ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString());

                bool userIsAdmin = await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString());

                vm.Permissions.IsAdmin    = userIsAdmin;
                vm.Permissions.CanEdit    = vm.UserId == CurrentUserId;
                vm.Permissions.CanFollow  = vm.UserId != CurrentUserId;
                vm.Permissions.CanConnect = vm.UserId != CurrentUserId;

                if (notificationclicked != Guid.Empty)
                {
                    notificationAppService.MarkAsRead(notificationclicked);
                }
            }

            ViewData["ConnecionTypes"] = EnumExtensions.ToJson(UserConnectionType.Mentor);

            return(View(vm));
        }
Example #20
0
        public bool IsParsingCompleted()
        {
            try
            {
                if (HttpRuntime.Cache[CurrentUserId.ToString()] != null && (bool)HttpRuntime.Cache[CurrentUserId.ToString()])
                {
                    HttpRuntime.Cache.ClearCache(CurrentUserId.ToString());
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }

            return(false);
        }
Example #21
0
        public async Task <IActionResult> DeleteProfile()
        {
            var user = await _userManager.FindByIdAsync(CurrentUserId.ToString());

            var result = await _userManager.DeleteAsync(user);

            if (!result.Succeeded)
            {
                return(BadRequest());
            }

            var profile = _profileRepository.GetProfile(CurrentUserId);

            profile.DoB    = null;
            profile.Gender = null;

            _profileRepository.SaveProfile(profile);

            return(Ok());
        }
Example #22
0
 protected void RadGridGrade_OnBatchEditCommand(object sender, GridBatchEditingEventArgs e)
 {
     foreach (var command in e.Commands)
     {
         if (command.Type.ToString() != "Delete")
         {
             command.NewValues["GradeSchemaId"] = RadGridGradeName.SelectedValue;
             if (command.NewValues["GradeSchemaItemId"] == null)
             {
                 command.NewValues["CreatedId"]   = CurrentUserId.ToString();
                 command.NewValues["CreatedDate"] = DateTime.Now;
             }
             else
             {
                 command.NewValues["UpdatedId"]   = CurrentUserId.ToString();
                 command.NewValues["UpdatedDate"] = DateTime.Now;
             }
         }
     }
 }
Example #23
0
        public void when_normal_user_tries_to_access_others_data_403_should_be_returned()
        {
            const int CurrentUserId = 32;
            const int OtherUsersId  = CurrentUserId + 1;

            var sampleCurrentUser = new Mock <ClaimsPrincipal>();

            sampleCurrentUser
            .Setup(user => user.IsInRole(RoleNames.NormalUser))
            .Returns(true);

            sampleCurrentUser
            .Setup(it => it.FindFirst(JwtRegisteredClaimNames.Sub))
            .Returns(new Claim(JwtRegisteredClaimNames.Sub, CurrentUserId.ToString()));

            var currentRouteData = new RouteData();

            typeof(RouteData)
            .GetField("_values", BindingFlags.Instance | BindingFlags.NonPublic)
            .SetValue(currentRouteData, new RouteValueDictionary
            {
                { "key", OtherUsersId }
            });

            var input = new AuthorizationFilterContext(new ActionContext(new DefaultHttpContext
            {
                User     = sampleCurrentUser.Object,
                Features =
                {
                    [typeof(IRoutingFeature)] = new RoutingFeature
                    {
                    RouteData = currentRouteData
                    }
                }
            }, currentRouteData, new ActionDescriptor(), new ModelStateDictionary()), new List <IFilterMetadata>());

            Sut.OnAuthorization(input);

            input.Result.ShouldBeOfType(typeof(StatusCodeResult));
            ((StatusCodeResult)input.Result).StatusCode.ShouldBe(403);
        }
Example #24
0
        public async Task <IActionResult> UpdateLogin([FromBody] ChangeLoginRequest model)
        {
            var user = await _userManager.FindByIdAsync(CurrentUserId.ToString());

            if (user == null)
            {
                return(Unauthorized());
            }
            var hasPassword = await _userManager.HasPasswordAsync(user);

            if (hasPassword)
            {
                var changePasswordResult = await _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);

                if (!changePasswordResult.Succeeded)
                {
                    return(BadRequest());
                }
            }
            else
            {
                var createPasswordResult = await _userManager.AddPasswordAsync(user, model.NewPassword);

                if (!createPasswordResult.Succeeded)
                {
                    return(BadRequest());
                }
            }
            if (!string.IsNullOrWhiteSpace(model.Username) && model.Username != user.UserName)
            {
                var setUsernameResult = await _userManager.SetUserNameAsync(user, model.Username);

                if (!setUsernameResult.Succeeded)
                {
                    return(BadRequest());
                }
            }

            return(Ok());
        }
        public async Task <IActionResult> GetDealList(int accountid, int index = 1, int limit = 10)
        {
            Dictionary <string, string> where = new Dictionary <string, string>
            {
                { "user_id", CurrentUserId.ToString() },//用户id
                { "account_id", accountid.ToString() }// 账户id
            };
            string condition = "";
            string empty     = " ";

            if (where.ContainsKey("user_id") && !string.IsNullOrEmpty(where["user_id"]))
            {
                condition += "and user_id=" + where["user_id"] + empty;
            }
            if (where.ContainsKey("account_id") && !string.IsNullOrEmpty(where["account_id"]))
            {
                condition += "and account_id=" + where["account_id"] + empty;
            }
            List <DealRecordDTO> list = await service.GetListAsync(CurrentUserId, index, limit, condition);

            return(Success(list));
        }
Example #26
0
        public ActionResult Edit(AdvertisementViewModel model)
        {
            if (model.UserId != CurrentUserId.ToString())
            {
                return(new HttpUnauthorizedResult());
            }

            ModelState.Remove(nameof(AdvertisementViewModel.Budget));
            ModelState.Remove(nameof(AdvertisementViewModel.ClickPrice));
            if (!ModelState.IsValid)
            {
                PopulateDropDownListAndKeys(model);
                return(View(model));
            }

            var ad = Mapper.Map <Advertisement>(model);

            ad.CreatedByAdmin = User.IsInRole(Constants.AdminRole);

            _adsService.Update(ad);
            return(RedirectToAction(nameof(Index)));
        }
Example #27
0
        public ActionResult Open(int id)
        {
            var ip    = Request.UserHostAddress;
            var model = _adsService.OpenAd(id, CurrentUserId.ToString(), ip);

            if (!string.IsNullOrEmpty(model.Link))
            {
                var link = LinkHelper.GetCorrectLink(model.Link);
                return(Redirect(link));
            }
            else
            {
                var companyId = model.User.CompanyId;
                if (companyId.HasValue)
                {
                    return(RedirectToAction("Details", "Business", new { id = companyId.Value }));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
        }
Example #28
0
        /// <include file='Docs/ExternalSummary.xml' path='docs/ShikiApi/method[@name="CreateMangaRate"]/*' />
        public MangaRate CreateMangaRate(int title_id, UserStatus status = (UserStatus)99, int score = -1, int volumes = -1, int chapters = -1)
        {
            List <KeyValuePair <string, string> > keys = new List <KeyValuePair <string, string> >();

            //Обязательные
            keys.AddRange(new[]
            {
                new KeyValuePair <string, string>("user_rate[user_id]", CurrentUserId.ToString()),
                new KeyValuePair <string, string>("user_rate[target_id]", title_id.ToString()),
                new KeyValuePair <string, string>("user_rate[target_type]", "Manga"),
            });

            //Необязательные
            if ((int)status != 99)
            {
                keys.Add(new KeyValuePair <string, string>("user_rate[status]", status.ToString()));
            }
            if (score >= 0)
            {
                keys.Add(new KeyValuePair <string, string>("user_rate[score]", score.ToString()));
            }
            if (volumes >= 0)
            {
                keys.Add(new KeyValuePair <string, string>("user_rate[volumes]", volumes.ToString()));
            }
            if (chapters >= 0)
            {
                keys.Add(new KeyValuePair <string, string>("user_rate[chapters]", chapters.ToString()));
            }

            var args = new FormUrlEncodedContent(keys);

            string url      = DomenApi + "v2/user_rates";
            var    response = Query.POST <_UserRate_v2>(url, args, this);

            return(new MangaRate(response));
        }
Example #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1");
                //scriptManager.Scripts.Add(new ScriptReference {Path = ResolveUrl("~/assets/js/jquery.flot.min.js")});
                //scriptManager.Scripts.Add(new ScriptReference {Path = ResolveUrl("~/assets/js/jquery.flot.time.min.js")});

                //GetChart();
            }

            // request
            LinqDataSourceRequest.WhereParameters.Clear();
            LinqDataSourceRequest.WhereParameters.Add("CurrentUserId", DbType.Int32, CurrentUserId.ToString());
            LinqDataSourceRequest.Where = "ApprovalUser == @CurrentUserId && CreatedId == @CurrentUserId";

            // approval
            LinqDataSourceApproval.WhereParameters.Clear();
            LinqDataSourceApproval.WhereParameters.Add("CurrentUserId", DbType.Int32, CurrentUserId.ToString());
            LinqDataSourceApproval.WhereParameters.Add("IsApprovalRequest", DbType.Boolean, Boolean.TrueString);
            LinqDataSourceApproval.WhereParameters.Add("ApprovalStatusCanceled", DbType.Int32, ((int)CConstValue.ApprovalStatus.Canceled).ToString());
            LinqDataSourceApproval.WhereParameters.Add("ApprovalStatusRejected", DbType.Int32, ((int)CConstValue.ApprovalStatus.Rejected).ToString());
            LinqDataSourceApproval.Where = "ApprovalStep = null && IsApprovalRequest == @IsApprovalRequest && (ApprovalUser = Supervisor) && Supervisor == @CurrentUserId && (ApprovalStatus != @ApprovalStatusCanceled && ApprovalStatus != @ApprovalStatusRejected)";
        }
Example #30
0
 private void GetSentMessage()
 {
     LinqDataSourceSentMessage.WhereParameters.Clear();
     LinqDataSourceSentMessage.WhereParameters.Add("CreatedId", DbType.Int32, CurrentUserId.ToString());
     LinqDataSourceSentMessage.Where = "CreatedId == @CreatedId";
 }