public WishListResponseModel Response(WishListModel wishListModel) { WishListResponseModel wishList = new WishListResponseModel(); wishList.WishListId = wishListModel.WishListID; wishList.UserId = wishListModel.UserId; wishList.BookId = wishListModel.BookId; wishList.CreatedDate = wishListModel.CreatedDate; return(wishList); }
// GET: /<controller>/ public IActionResult Index() { if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { IEnumerable <WishListOutputModel> OutPutData = null; WishListInputModel filter = new WishListInputModel(); filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID)); filter.PageSize = 1000; filter.PageNumber = 1; using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Site/"); var responseTask = client.PostAsJsonAsync <WishListInputModel>("GetWishList", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); WishListResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <WishListResponseModel>(content.Result); OutPutData = resutl.data; } else //web api sent error response { //log response status here.. OutPutData = Enumerable.Empty <WishListOutputModel>(); ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } return(View(OutPutData)); } else { TempData["CustomError"] = "Silakan masuk sebelum menggunakan situs web."; //if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV") //{ // return RedirectToAction("AdminLogon", "Login"); //} //else if (HttpContext.Session.GetString(Loginfrom) == "MDO") //{ // return RedirectToAction("OwnerLogon", "Login"); //} //else //{ // return RedirectToAction("OwnerLogon", "Login"); //} return(RedirectToAction("Logon", "Login")); } }
public List <WishListResponseModel> GetAllWishListValues() { try { List <WishListResponseModel> wishListResponseList = new List <WishListResponseModel>(); var wishListResponse = this.dbContext.WishList; foreach (var response in wishListResponse) { WishListResponseModel wishList = new WishListResponseModel(); if (response.IsDeleted == "No" && response.IsMoved == "No") { wishList = Response(response); wishListResponseList.Add(wishList); } } return(wishListResponseList); } catch (Exception e) { throw new Exception(e.Message); } }
public ActionResult <WishListResponseModel> GetWishList([FromBody] WishListInputModel data) { WishListResponseModel res = new WishListResponseModel(); try { WishListBL bl = new WishListBL(DbContext); var temp = bl.GetWishList(data).ToList(); res.data = temp; res.Message = "Success"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }