public ActionResult GetRequestOnUser(SearchByUser user) { if (ModelState.IsValid) { if (user.NeedDate) { var ListReq = db.GetRequestByUser(user.UserId, Convert.ToDateTime(user.StartDate), Convert.ToDateTime(user.FinalDate)); if (ListReq.Count > 0) { return(PartialView("GetRequest", ListReq)); } else { return(PartialView("Warning", new Message { TextMessage = "Нет данных в БД" })); } } else { return(PartialView("GetRequest", db.GetRequestByUser(user.UserId))); } } else { var errors = ModelState.Values.Where(e => e.Errors.Count > 0).SelectMany(e => e.Errors).Select(e => e.ErrorMessage).Distinct().Select(x => new Message { TextMessage = x }).ToList(); return(PartialView("Error", errors)); } }
public SearchByUser SearchByUser(string email, int id) { SearchByUser searchResult = new SearchByUser(); var product = this.db.Products.SingleOrDefault(p => p.Id == id); var user = userManager.FindByEmailAsync(email).Result; searchResult.productId = product.Id; searchResult.Name = product.Name; searchResult.Price = product.Price; searchResult.Discount = product.Discount; searchResult.User = user; searchResult.Roles = userManager.GetRolesAsync(user).Result; return(searchResult); }