public StudentProfileResponse GetUserProfile(string studentId) { StudentProfileResponse user = null; try { services = new UserDetailsService(); user = services.GetUserDetails(studentId); } catch (Exception ex) { } return(user); }
public void GetUserDetails_Return_APiResponse_Success_When_No_Error() { var response = _userDetailsService.GetUserDetails(PassModel().Name); Assert.AreEqual("Success", response.status); }
public ActionResult FinishOrder(UserDetails submitedDetails = null) { Order order = new Order(); Cart cartOfUser = new Cart(); if (User.Identity.IsAuthenticated) { cartOfUser = CartService.GetCart(User.Identity.GetUserId()); } else { if (Request.Cookies["Guest"] != null) { cartOfUser = CartService.GetCart(Request.Cookies["Guest"].Value); } else { return(RedirectToAction("Index", "Home")); } } UserDetails details = new UserDetails(); if (User.Identity.IsAuthenticated) { details = UserDetailsService.GetUserDetails(User.Identity.GetUserId()); } else { details = UserDetailsService.GetUserDetails(Request.Cookies["Guest"].Value); details.UserId = "guestid"; } if (cartOfUser.ProductsInCart.Count > 0) { Order newOrder = new Order(cartOfUser, details); if (!details.PromoCode.Equals("")) { newOrder = ApplyPromoCode(newOrder, details.PromoCode); } try { CreateAndSaveOrder(newOrder); return(RedirectToAction("Index", "Home", new { message = "OrderPlaced" })); } catch (DbEntityValidationException e) { return(RedirectToAction("Index", "Home")); var errorfeed = ""; foreach (var eve in e.EntityValidationErrors) { errorfeed += String.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { errorfeed += String.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw new Exception(errorfeed); } return(RedirectToAction("Index", "Manage")); } return(RedirectToAction("Cart", "Manage")); }