public JsonResult AddToCart(CtGiohangViewModel ctGiohangVm) { try { if (Session[CommonConstrants.USER_SESSION] != null) { var user = _userService.GetUser(UserLoginViewModel.Current.KeyId); ctGiohangVm.User_FK = user.KeyId; CtGiohang ct = Mapper.Map <CtGiohangViewModel, CtGiohang>(ctGiohangVm); var temp = user.KhachhangNavigation.CtGiohangs.FirstOrDefault(x => x.masp == ct.masp); if (temp == null) { user.KhachhangNavigation.CtGiohangs.Add(ct); } else { temp.soluong += ct.soluong; } if (_userService.Save()) { return(Json(new { Result = Notification.LIKE_PRODUCT, Status = "OK" }, JsonRequestBehavior.AllowGet)); } return(Json(new { Result = Notification.NOT_ADD_TO_CART, Status = "FAIL" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Result = Notification.LIKE_NOT_LOGIN, Status = "FAIL" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Result = ex.Message, Status = "FAIL" }, JsonRequestBehavior.AllowGet)); } }
public void Update(CtGiohangViewModel loaispVm) { throw new NotImplementedException(); }
public CtGiohangViewModel Add(CtGiohangViewModel loaispVm) { throw new NotImplementedException(); }