public void FillDatabaseWithUsers() { var context = new FoodOrderDbContext().CreateDbContext(null); var repo = new FoodOrderRepository(context); var prevCount = repo.All <User>().Count(); repo.InsertAsync( new[] { new User { Email = "*****@*****.**", UserName = "******" }, new User { Email = "*****@*****.**", UserName = "******" }, new User { Email = "*****@*****.**", UserName = "******" }, new User { Email = "*****@*****.**", UserName = "******" } }); repo.Save(); var currentCount = repo.All <User>().Count(); var diff = currentCount - prevCount; Assert.Equal(4, diff); }
public static TodaysOrder GetObjectData() { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var todaydate = DateTime.Now.ToString("dd/MM/yyyy"); var TodaysOrder = new TodaysOrder { TotalItems = db.FoodItems.Where(s => s.isEnabled == true).Count(), TotalUsers = db.Users.Count(), OrderDelivered = db.Orders.Where(s => s.status == "Complete").Count(), OrderPending = db.Orders.Where(s => s.status != "Complete").Count(), Order = db.Orders.Join(db.Users, o => o.userId, u => u.userId, (o, u) => new { o, u }).OrderByDescending(s => s.o.status == "Pending").Where(s => s.o.dateTime.Contains(todaydate)).Select(s => new OrderModel { orderId = s.o.orderId, CustomerName = s.u.username, dateTime = s.o.dateTime, status = s.o.status, totalPrice = s.o.totalPrice, }).ToList() }; return(TodaysOrder); } }
public JsonResult SavePaymentRecord(IList <OrderNow> values) { if (values != null) { decimal amount = GeneralModel.GetTotalAmount(values); var response = ChargeCreditCard.Run(amount); if (response.refId != null) { Order newOrder = new Order(); newOrder.userId = Convert.ToInt32(Session["UserId"].ToString()); newOrder.dateTime = DateTime.Now.ToString("HH:mm tt dd/MM/yyyy"); newOrder.status = "Pending"; newOrder.totalPrice = amount.ToString(); newOrder.transId = response.refId; using (FoodOrderDbContext db = new FoodOrderDbContext()) { db.Orders.Add(newOrder); db.SaveChanges(); } foreach (var item in values) { decimal itemid = GeneralModel.GetItemID(item.Name); decimal orderId = GeneralModel.GetOrderId(); decimal quantity = item.count; GeneralModel.SavetoItemDetials(itemid, orderId, quantity); GeneralModel.UpdateQuantity(itemid, quantity); } } return(Json(new { result = 1 }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = 0 }, JsonRequestBehavior.AllowGet)); }
public async Task AddDishItem() { var context = new FoodOrderDbContext().CreateDbContext(null); var repo = new FoodOrderRepository(context); var date = DateTime.Now; var dishItem = new DishItem { Name = "Salo", Price = 100, Category = new DishCategory { Name = "Еда богов" }, Supplier = repo.All <Supplier>().FirstOrDefault(x => x.Name == "ГлаголЪ"), AvailableOn = new List <DishItemToWeekDay> { new DishItemToWeekDay { WeekDay = repo.GetById <WeekDay>(1) } }, AvailableUntil = date }; await repo.InsertAsync(dishItem); await repo.SaveAsync(); var i = repo.All <DishItem>().Include(x => x.AvailableOn).FirstOrDefault(x => x.AvailableUntil == date); Assert.Equal(dishItem.AvailableOn.First().DishItemId, i.AvailableOn.First().DishItemId); Assert.Equal(dishItem.AvailableOn.First().WeekDayId, i.AvailableOn.First().WeekDayId); }
public async Task TestSync() { var context = new FoodOrderDbContext().CreateDbContext(null); var repo = new FoodOrderRepository(context); var service = new FoodService(repo, new GoogleSpreadsheetProvider()); await service.SynchronizeFood(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, FoodOrderDbContext context) { app.UseAuthentication(); app.UseMiddleware <AuthenticatedTestRequestMiddleware>(); // automatikus "bejelentkezés" app.UseMvc(); TestDbInitializer.Initialize(context); }
public static decimal GetUserId(string email) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var id = db.Users.Where(s => (s.username == email)).Select(s => s.userId).FirstOrDefault(); return(id); } }
public ServerClientFixture() { // Arrange Server = new TestServer(new WebHostBuilder() .UseStartup <TestStartup>()); Context = Server.Host.Services.GetRequiredService <FoodOrderDbContext>(); Client = Server.CreateClient(); }
public static void UpdateQuantity(decimal itemid, decimal quantity) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { decimal Updatedquantity = GetUpdatedQuantity(quantity, itemid); FoodItem updateItem = db.FoodItems.Find(itemid); updateItem.quantity = Convert.ToInt32(Updatedquantity); db.SaveChanges(); } }
public static decimal GetOrderId() { decimal id = 0; using (FoodOrderDbContext db = new FoodOrderDbContext()) { id = db.Orders.OrderByDescending(s => s.orderId).Select(s => s.orderId).FirstOrDefault(); } return(id); }
public static decimal GetItemID(string name) { decimal id = 0; using (FoodOrderDbContext db = new FoodOrderDbContext()) { id = db.FoodItems.Where(s => s.name.Contains(name)).Select(s => s.itemId).FirstOrDefault(); } return(id); }
public JsonResult GetProductsById(int id) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var catName = db.Categories.Where(s => s.catId == id).Select(s => s.name).FirstOrDefault(); var data = ItemViewModel.GetItemsData(id); return(Json(new { Data = data, CategoryName = catName }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddNewCategory(string CategoryName) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { Category cat = new Category(); cat.name = CategoryName; db.Categories.Add(cat); db.SaveChanges(); } return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); }
public static decimal GetUpdatedQuantity(decimal quantity, decimal itemid) { decimal updateQuantity = 0; using (FoodOrderDbContext db = new FoodOrderDbContext()) { var TotalQuantity = db.FoodItems.Where(s => s.itemId == itemid).Select(s => s.quantity).FirstOrDefault(); updateQuantity = Convert.ToDecimal(TotalQuantity) - quantity; } return(updateQuantity); }
public ActionResult DeleteItem(int id) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var finddata = db.FoodItems.Find(id); finddata.isDeleted = true; db.SaveChanges(); } return(new JsonResult { Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public static bool VerifyCategory(string categoryName) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var name = db.Categories.Where(s => s.name == categoryName).Count(); if (name >= 1) { return(true); } } return(false); }
public ActionResult EditPrice(string Price, int itemId) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { FoodItem updateprice = db.FoodItems.Find(itemId); updateprice.price = Price; db.SaveChanges(); return(new JsonResult { Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public static bool VerifyUserNameAndPassword(string email, string password) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var rec = db.Users.Where(s => (s.username == email && s.password == password)).Count(); if (rec == 1) { return(true); } } return(false); }
public static bool VerifyEmail(string username) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var rec = db.Users.Where(s => s.username == username).Count(); if (rec >= 1) { return(true); } } return(false); }
public static void SavetoItemDetials(decimal itemid, decimal orderId, decimal quantity) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { OrderDetail orderD = new OrderDetail(); orderD.itemId = itemid; orderD.orderId = orderId; orderD.quantity = quantity.ToString(); db.OrderDetails.Add(orderD); db.SaveChanges(); } }
public static void SaveRecord(SignUpModel data) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { User adduser = new User(); adduser.email = data.email; adduser.username = data.UserName; adduser.password = data.password; db.Users.Add(adduser); db.SaveChanges(); } }
public static CategoryModel GetCategory() { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var cat = new CategoryModel { category = db.Categories.Join(db.FoodItems, c => c.catId, f => f.catId, (c, f) => new { c, f }).Select(s => new ListCategory { catId = s.c.catId, name = s.c.name }).Distinct().ToList() }; return(cat); } }
public JsonResult IsEmailExist(string Email) { var status = false; using (FoodOrderDbContext db = new FoodOrderDbContext()) { var result = db.Users.Where(s => (s.email == Email)).Count(); if (result > 0) { status = true; } } return(Json(new { result = status }, JsonRequestBehavior.AllowGet)); }
public JsonResult isUserExist(string UserName) { var status = false; using (FoodOrderDbContext db = new FoodOrderDbContext()) { var result = db.Users.Where(s => (s.username == UserName)).Count(); if (result > 0) { status = true; } } return(Json(new { result = status }, JsonRequestBehavior.AllowGet)); }
public static CategoryViewModel GetCatagoryData() { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var catData = new CategoryViewModel { Category = db.Categories.Select(s => new CatagoryModel { CategoryId = s.catId, CategoryName = s.name }).OrderByDescending(s => s.CategoryId).ToList() }; return(catData); } }
public ActionResult OrderDeliver(int id) { var OrderDelivered = 0; var OrderPending = 0; using (FoodOrderDbContext db = new FoodOrderDbContext()) { var finddata = db.Orders.Find(id); finddata.status = "Complete"; db.SaveChanges(); OrderDelivered = db.Orders.Where(s => s.status == "Complete").Count(); OrderPending = db.Orders.Where(s => s.status != "Complete").Count(); } return(Json(new { OrderDeliver = OrderDelivered, OrderPending = OrderPending, Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet })); }
public static UserViewModel GetUserDetails() { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var UserData = new UserViewModel { User = db.Users.Select(f => new UserModel { userId = f.userId, username = f.username, email = f.email }).ToList() }; return(UserData); } }
public static ItemViewModel GetItemsData(int id) { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var itemData = new ItemViewModel { Items = db.FoodItems.Where(s => s.isEnabled == true && s.isDeleted == false && s.catId == id && s.quantity > 0).Select(s => new ItemsModel { itemId = s.itemId, price = s.price, name = s.name, image = s.image, quantity = s.quantity }).OrderBy(x => Guid.NewGuid()).ToList() }; return(itemData); } }
public void TestDb() { var context = new FoodOrderDbContext().CreateDbContext(null); context.WeekDays.Add(new WeekDay { Name = "Wd" }); context.SaveChanges(); var t = context.WeekDays.FirstOrDefault(x => x.Name == "Wd"); Assert.Equal("Wd", t.Name); context.Remove(t); context.SaveChanges(); var w = context.WeekDays.FirstOrDefault(x => x.Name == "Wd"); Assert.Null(w); }
public static TranscationModel GetTranscationData() { using (FoodOrderDbContext db = new FoodOrderDbContext()) { var orderOrder = new TranscationModel { Order = db.Orders.Join(db.Users, o => o.userId, u => u.userId, (o, u) => new { o, u }).OrderByDescending(s => s.o.dateTime).Take(20).Select(s => new OrderModel { orderId = s.o.orderId, CustomerName = s.u.username, TranscationId = s.o.transId, dateTime = s.o.dateTime, status = s.o.status, totalPrice = s.o.totalPrice, }).ToList() }; return(orderOrder); } }