public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, string firstName = null, string lastName = null, string maidenName = null, Sex?sex    = null,
                                    RelationType?relation = null, long?relationPartnerId = null, DateTime?birthDate = null, BirthdayVisibility?birthDateVisibility = null,
                                    string homeTown       = null, long?countryId = null, long?cityId = null)
        {
            VkErrors.ThrowIfNumberIsNegative(() => relationPartnerId);
            VkErrors.ThrowIfNumberIsNegative(() => countryId);
            VkErrors.ThrowIfNumberIsNegative(() => cityId);

            changeNameRequest = null;

            var parameters = new VkParameters
            {
                { "first_name", firstName },
                { "last_name", lastName },
                { "maiden_name", maidenName },
                { "sex", ((sex ?? Sex.Unknown) == Sex.Unknown) ? null : sex },
                { "relation", relation },
                { "relation_partner_id", relationPartnerId },
                { "bdate", birthDate != null?birthDate.Value.ToString("dd.MM.yyyy") : null },
                { "bdate_visibility", birthDateVisibility },
                { "home_town", homeTown },
                { "country_id", countryId },
                { "city_id", cityId }
            };

            var response = _vk.Call("account.saveProfileInfo", parameters);

            changeNameRequest = response["name_request"];
            return(response["changed"]);
        }
예제 #2
0
        public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, string firstName = null, string lastName = null, string maidenName = null, Sex?sex    = null,
                                    RelationType?relation = null, long?relationPartnerId = null, DateTime?birthDate = null, BirthdayVisibility?birthDateVisibility = null,
                                    string homeTown       = null, long?countryId = null, long?cityId = null)
        {
            var parameters = new AccountSaveProfileInfoParams
            {
                FirstName       = firstName,
                LastName        = lastName,
                MaidenName      = maidenName,
                Sex             = sex.Value,
                Relation        = relation.Value,
                RelationPartner = relationPartnerId.HasValue ? new User
                {
                    Id = relationPartnerId.Value
                } : null,
                BirthDate          = birthDate?.ToShortDateString(),
                BirthdayVisibility = birthDateVisibility.Value,
                HomeTown           = homeTown,
                Country            = new Country {
                    Id = countryId
                },
                City = new City {
                    Id = cityId
                }
            };

            return(SaveProfileInfo(out changeNameRequest, parameters));
        }
예제 #3
0
        public bool UpdateName(ChangeNameRequest request)
        {
            var item = Inventory.FindById(request.Id);

            item.Name = request.Name;
            return(Inventory.Update(item));
        }
예제 #4
0
        public bool UpdateInventoryItemName(ChangeNameRequest request)
        {
            var item = GetInventoryItemById(request.Id);

            item.Name = request.Name;             // changes to the fetch object are tracked by default.
            // calling save changes will update all tracked items with their new data.
            return(_context.SaveChanges() != 0);
        }
예제 #5
0
        public ActionResult ChangeName(ChangeNameRequest model)
        {
            var response = _UserService.ChangeName(model);

            if (response == null)
            {
                return(BadRequest("Something went wrong..."));
            }

            return(Ok(response));
        }
예제 #6
0
        public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, AccountSaveInfoParams @params)
        {
            VkErrors.ThrowIfNumberIsNegative(() => @params.RelationPartnerId);
            VkErrors.ThrowIfNumberIsNegative(() => @params.CountryId);
            VkErrors.ThrowIfNumberIsNegative(() => @params.CityId);

            var response = _vk.Call("account.saveProfileInfo", @params);

            changeNameRequest = response["name_request"];
            return(response["changed"]);
        }
예제 #7
0
        public Profile NameChange([FromBody] ChangeNameRequest entity)
        {
            entity.PublicID = User.Identity.Name;
            ResponseMessage <Profile> request = _profileService.ChangeName(entity);

            if (!request.IsSuccess)
            {
                throw new Exception(request.ErrorMessage);
            }

            return(request.ResponseObject);
        }
예제 #8
0
        public async Task <IActionResult> ChangeName(int listId, ChangeNameRequest request)
        {
            var authorisationResponse = await _listAuthoriser.IsOwner(listId, _userProfileId);

            if (!authorisationResponse.AuthorisationResult)
            {
                return(NotFound());
            }

            await _listWriter.ChangeName(listId, request.Name);

            return(Ok());
        }
예제 #9
0
        /// <summary>
        /// Редактирует информацию текущего профиля.
        /// </summary>
        /// <param name="changeNameRequest">
        /// Если в параметрах передавалось имя или фамилия пользователя,
        /// в этом параметре будет возвращен объект типа ChangeNameRequest
        /// </param>
        /// <param name="params"> The parameters. </param>
        /// <returns>
        /// Результат отмены заявки.
        /// </returns>
        /// <remarks>
        /// Страница документации ВКонтакте http://vk.com/dev/account.saveProfileInfo
        /// </remarks>
        public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, AccountSaveProfileInfoParams @params)
        {
            var response = _vk.Call(methodName: "account.saveProfileInfo", parameters: @params);

            changeNameRequest = null;

            if (response.ContainsKey(key: "name_request"))
            {
                changeNameRequest = response[key : "name_request"];
            }

            return(response[key : "changed"]);
        }
        public virtual async Task <IStatusResponse> ChangeNameAsync(
            ChangeNameRequest model, CancellationToken token = default)
        {
            model.ArgumentNullCheck(nameof(model));

            using (var scope = TransactionFactory.CreateTransaction())
            {
                var result = await service.ChangeNameAsync(model, token)
                             .ConfigureAwaitFalse();

                scope.Complete();

                return(result);
            }
        }
예제 #11
0
        public string ChangeName(ChangeNameRequest model)
        {
            var user = _Users.Find(x => x.Id == model.id).SingleOrDefault();

            if (user == null)
            {
                return(null);
            }


            user.name = model.name;

            _Users.ReplaceOne(sub => sub.Id == model.id, user);


            return(generateJwtToken(user));
        }
        public ResponseMessage <Profile> ChangeName(ChangeNameRequest entity)
        {
            ResponseMessage <Profile> response = new ResponseMessage <Profile>();
            Profile profileEntity = _profileRepository.GetByID(entity.PublicID.Reverse());

            try
            {
                profileEntity.Name      = entity.NewName;
                response.ResponseObject = _profileRepository.ChangeName(profileEntity);
                response.IsSuccess      = true;
                response.ErrorMessage   = "Success";
            }
            catch (Exception ex)
            {
                response.IsSuccess    = false;
                response.ErrorMessage = ex.Message;
            }

            return(response);
        }
예제 #13
0
        public virtual async Task <IStatusResponse> ChangeNameAsync(
            ChangeNameRequest model, CancellationToken token = default)
        {
            model.ArgumentNullCheck(nameof(model));

            var entity = await store.GetEntityAsync(model.Id, token);

            IStatusResponse response;

            if (entity == null)
            {
                response = NotFoundStatusResponse(model.Id);
            }
            else
            {
                model.Name.UpdateEntity(entity.Name);
                await context.SaveChangesAsync(token);

                response = new StatusResponse(entity.Id);
            }

            return(response);
        }
예제 #14
0
        public async Task <IActionResult> ChangeName([FromBody] ChangeNameRequest request)
        {
            try
            {
                var thisUserId = ClaimsExtractor.GetUserIdClaim(User.Claims);

                await mUsersService.ChangeName(request.newName, thisUserId);

                return(Ok(new ResponseApiModel <bool>
                {
                    IsSuccessfull = true
                }));
            }
            catch (InvalidDataException ex)
            {
                return(BadRequest(new ResponseApiModel <bool>
                {
                    IsSuccessfull = false,
                    ErrorMessage = ex.Message
                }));
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound(new ResponseApiModel <bool>
                {
                    IsSuccessfull = false,
                    ErrorMessage = ex.Message
                }));
            }
            catch (Exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiModel <bool>
                {
                    IsSuccessfull = false
                }));
            }
        }
예제 #15
0
        public IEnumerable <ChangeNameRequest> GetNameAndIdsInStorageLocation(string location)
        {
            var items = Inventory.Find(x => x.StorageLocation == location);

            var requests = new List <ChangeNameRequest>();

            for (int i = 0; i < items.Count(); i++)
            {
                var n = new ChangeNameRequest()
                {
                    Name = items.ElementAt(i).Name,
                    Id   = items.ElementAt(i).Id
                };
                requests.Add(n);
            }
            return(items.Select(x =>
            {
                return new ChangeNameRequest
                {
                    Id = x.Id,
                    Name = x.Name
                };
            }));
        }
예제 #16
0
파일: AccountCategory.cs 프로젝트: vknet/vk
        /// <summary>
        /// Редактирует информацию текущего профиля.
        /// </summary>
        /// <param name="changeNameRequest">Если в параметрах передавалось имя или фамилия пользователя,
        /// в этом параметре будет возвращен объект типа <see cref="ChangeNameRequest" />, содержащий информацию о заявке на смену имени.</param>
        /// <param name="params">The parameters.</param>
        /// <returns>
        /// Результат отмены заявки.
        /// </returns>
        /// <remarks>
        /// Страница документации ВКонтакте <seealso cref="http://vk.com/dev/account.saveProfileInfo" />.
        /// </remarks>
        public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, AccountSaveProfileInfoParams @params)
        {
            var response = _vk.Call("account.saveProfileInfo", @params);

            changeNameRequest = null;

            if (response.ContainsKey("name_request"))
            {
                changeNameRequest = response["name_request"];
            }

            return response["changed"];
        }
예제 #17
0
		public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, string firstName = null, string lastName = null, string maidenName = null, Sex? sex = null,
			RelationType? relation = null, long? relationPartnerId = null, DateTime? birthDate = null, BirthdayVisibility? birthDateVisibility = null,
			string homeTown = null, long? countryId = null, long? cityId = null)
		{
			VkErrors.ThrowIfNumberIsNegative(() => relationPartnerId);
			VkErrors.ThrowIfNumberIsNegative(() => countryId);
			VkErrors.ThrowIfNumberIsNegative(() => cityId);
			
			changeNameRequest = null;
			
			var parameters = new VkParameters
									{
										{"first_name", firstName},
										{"last_name", lastName},
										{"maiden_name", maidenName},
										{"sex", ((sex ?? Sex.Unknown) ==  Sex.Unknown) ? null : sex},
										{"relation", relation},
										{"relation_partner_id", relationPartnerId},
										{"bdate", birthDate != null ? birthDate.Value.ToString("dd.MM.yyyy") : null},
										{"bdate_visibility", birthDateVisibility},
										{"home_town", homeTown},
										{"country_id", countryId},
										{"city_id", cityId}
									};

			var response = _vk.Call("account.saveProfileInfo", parameters);

			changeNameRequest = response["name_request"];
			return response["changed"];

		}
예제 #18
0
		public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, AccountSaveInfoParams @params)
		{
			VkErrors.ThrowIfNumberIsNegative(() => @params.RelationPartnerId);
			VkErrors.ThrowIfNumberIsNegative(() => @params.CountryId);
			VkErrors.ThrowIfNumberIsNegative(() => @params.CityId);

			var response = _vk.Call("account.saveProfileInfo", @params);

			changeNameRequest = response["name_request"];
			return response["changed"];
		}
예제 #19
0
		public bool SaveProfileInfo(out ChangeNameRequest changeNameRequest, string firstName = null, string lastName = null, string maidenName = null, Sex? sex = null,
			RelationType? relation = null, long? relationPartnerId = null, DateTime? birthDate = null, BirthdayVisibility? birthDateVisibility = null,
			string homeTown = null, long? countryId = null, long? cityId = null)
		{
			var parameters = new AccountSaveInfoParams
			{
				FirstName = firstName,
				LastName = lastName,
				MaidenName = maidenName,
				Sex = sex.Value,
				Relation = relation.Value,
				RelationPartnerId = relationPartnerId,
				BirthDate = birthDate,
				BirthDateVisibility = birthDateVisibility.Value,
				HomeTown = homeTown,
				CountryId = countryId,
				CityId = cityId
			};

			return SaveProfileInfo(out changeNameRequest, parameters);

		}
예제 #20
0
        public async Task <IActionResult> PatchName([Required] ChangeNameRequest model, CancellationToken token)
        {
            var result = await service.ChangeNameAsync(model, token);

            return(GenerateResponse(result));
        }
 public bool UpdateName(ChangeNameRequest request)
 {
     return(_service.UpdateName(request));
 }
예제 #22
0
 public bool UpdateName(ChangeNameRequest request)
 {
     // return _liteDbService.UpdateName(request);
     return(_dataService.UpdateInventoryItemName(request));
 }