public async Task Follow_UnFollow_Category(CategoryFollowers entity) { var response = await _httpService.Post <CategoryFollowers>($"{url}/Follow_UnFollow_Category", entity); if (!response.Success) { throw new ApplicationException(await response.GetBody()); } }
public async Task <ActionResult> Follow_UnFollow_Category(CategoryFollowers 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_Category(entity); #region End the watch watch.Stop(); result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds; #endregion return(Ok(result)); }
public async Task <ApiResponse> Follow_UnFollow_Category(CategoryFollowers input) { try { var categoryFollowerDB = await _categoryFollowersRepository.Table.Where(x => x.UserCId == input.UserCId && x.CategoryId == input.CategoryId).SingleOrDefaultAsync(); if (categoryFollowerDB != null) { categoryFollowerDB.Status = input.Status; await _storeFollowersRepository.SaveChangesAsync(); } else { await _categoryFollowersRepository.InsertAsync(new CategoryFollowers { UserCId = input.UserCId, CategoryId = input.CategoryId, Status = input.Status }); } return(ApiResponse.Create(HttpStatusCode.OK, null)); } catch (Exception) { return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error")); } }