예제 #1
0
        public async Task Follow_UnFollow_Store(StoreFollowers entity)
        {
            var response = await _httpService.Post <StoreFollowers>($"{url}/Follow_UnFollow_Store", entity);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }
        }
예제 #2
0
        public async Task <ActionResult> Follow_UnFollow_Store(StoreFollowers entity)
        {
            #region Start the watch
            var watch = new Stopwatch();
            watch.Start();
            #endregion

            entity.UserCId = (await _userCServices.GetCurrent(User.Identity.Name)).Id;
            var result = await _favouritesServices.Follow_UnFollow_Store(entity);

            #region End the watch
            watch.Stop();
            result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds;
            #endregion

            return(Ok(result));
        }
        public async Task <ApiResponse> Follow_UnFollow_Store(StoreFollowers input)
        {
            try
            {
                var storeFollowerDB = await _storeFollowersRepository.Table.Where(x => x.UserCId == input.UserCId && x.StoreId == input.StoreId).SingleOrDefaultAsync();

                if (storeFollowerDB != null)
                {
                    storeFollowerDB.Status = input.Status;
                    await _storeFollowersRepository.SaveChangesAsync();
                }
                else
                {
                    await _storeFollowersRepository.InsertAsync(new StoreFollowers { UserCId = input.UserCId, StoreId = input.StoreId, Status = input.Status });
                }
                return(ApiResponse.Create(HttpStatusCode.OK, null));
            }
            catch (Exception)
            {
                return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error"));
            }
        }