public TestWeekMenuController() { _unitOfWork = new UnitOfWork(new ApplicationDbContext()); _db = _unitOfWork.GetContext(); _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync <MenuForWeek>()); _userManager = new ApplicationUserManager(new UserStore <User>(_unitOfWork.GetContext())); }
public async Task <IHttpActionResult> UpdateUserWeekOrder([FromBody] UpdateUserOrderDto userOrderDto) { string userid = RequestContext.Principal.Identity.GetUserId(); if (userOrderDto == null) { return(BadRequest("Bad Request Object")); } DayOrderMenu dayord = _unitOfWork.RepositoryAsync <DayOrderMenu>() .Query() .Include(dord => dord.MenuForDay) .Select() .FirstOrDefault(dord => dord.Id == userOrderDto.DayOrderId); if (dayord == null) { return(BadRequest("Bad Request Object")); } if (!dayord.MenuForDay.OrderCanBeChanged) { return(Ok("noordchenged")); } User curuser = _db.Users.Find(userid); _unitOfWork.GetContext().UpdateDishQuantity(userOrderDto); return(Ok(curuser.Balance)); }
public TestWeekMenuController() { _unitOfWork = new UnitOfWork(new ApplicationDbContext()); _db = _unitOfWork.GetContext(); _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>()); _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext())); }
public async Task <IHttpActionResult> UpdateAccount([FromBody] UpdateAccountEmailDto accountEmailDto) { User user = await UserManager.FindByIdAsync(accountEmailDto.UserId); user.Email = accountEmailDto.Email; _unitOfWork.GetContext().Entry(user).State = EntityState.Modified; await _unitOfWork.SaveChangesAsync(); return(Ok(true)); }
public static WeekOrderDto GetMapDto(IUnitOfWorkAsync unitOfWork, WeekYearDto wyDto, bool needfact = true) { ApplicationDbContext context = unitOfWork.GetContext(); MenuForWeek menuForWeek = unitOfWork.RepositoryAsync <MenuForWeek>().GetWeekMenuByWeekYear(wyDto); if (menuForWeek == null) { return(null); } List <WeekOrderMenu> weekOrderMenus = unitOfWork.RepositoryAsync <WeekOrderMenu>() .OrdersMenuByWeekYear(wyDto).Where(word => word.User.IsExisting).OrderBy(wo => wo.User.LastName).ToList(); return(new WeekOrderDto { WeekYearDto = wyDto, SuCanChangeOrder = menuForWeek.SUCanChangeOrder, UserWeekOrders = weekOrderMenus.Select(woDto => UserWeekOrderDto.MapDto(context, woDto)).ToList(), DayNames = context.GetDayNames(wyDto, true).Result, WeekDishPrices = context.GetWeekDishPrices(wyDto).Result, SummaryDishQuantities = context.GetFactSumWeekUserCounts(wyDto).Result, AllDayNames = context.GetDayNames(wyDto).Result }); }
public WeekMenuController(IUnitOfWorkAsync unitOfWork) { _unitOfWork = unitOfWork; _db = _unitOfWork.GetContext(); _weekmenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync <MenuForWeek>()); _mfdDishPriceService = new MfdDishPriceService(_unitOfWork.RepositoryAsync <MfdDishPriceRelations>()); }
public WeekMenuController(IUnitOfWorkAsync unitOfWork) { _unitOfWork = unitOfWork; _db = _unitOfWork.GetContext(); _weekmenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>()); _mfdDishPriceService=new MfdDishPriceService(_unitOfWork.RepositoryAsync<MfdDishPriceRelations>()); }
public static void UpdateBalanceByDayMenuCanged(int daimenu) { IUnitOfWorkAsync unitOfWork = DependencyResolver.Current.GetService <IUnitOfWorkAsync>(); List <WeekOrderMenu> unitList = unitOfWork.RepositoryAsync <WeekOrderMenu>().GetWeekUsersOrdByDayMenuId(daimenu); unitList.ForEach(uord => unitOfWork.GetContext().UpdateBalanceByWeekOrderId(uord.Id)); }
public EmployeeOrderApiController(IUnitOfWorkAsync unitOfWorkAsync) { _unitOfWork = unitOfWorkAsync; _db = unitOfWorkAsync.GetContext(); _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>()); _orderMenuService = new OrderMenuService(_unitOfWork.RepositoryAsync<WeekOrderMenu>()); _weekPaimentService = new WeekPaimentService(_unitOfWork.RepositoryAsync<WeekPaiment>()); }
public EmployeeOrderApiController(IUnitOfWorkAsync unitOfWorkAsync) { _unitOfWork = unitOfWorkAsync; _db = unitOfWorkAsync.GetContext(); _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync <MenuForWeek>()); _orderMenuService = new OrderMenuService(_unitOfWork.RepositoryAsync <WeekOrderMenu>()); _weekPaimentService = new WeekPaimentService(_unitOfWork.RepositoryAsync <WeekPaiment>()); }
public MigrationTest() { _unitOfWork = new UnitOfWork(new ApplicationDbContext()); dataContext = _unitOfWork.GetContext(); IRepositoryAsync<MenuForWeek> menuRepo = _unitOfWork.RepositoryAsync<MenuForWeek>(); _menuForWeekService = new MenuForWeekService(menuRepo); _userManager = new ApplicationUserManager(new UserStore<User>(dataContext)); }
public MigrationTest() { _unitOfWork = new UnitOfWork(new ApplicationDbContext()); dataContext = _unitOfWork.GetContext(); IRepositoryAsync <MenuForWeek> menuRepo = _unitOfWork.RepositoryAsync <MenuForWeek>(); _menuForWeekService = new MenuForWeekService(menuRepo); _userManager = new ApplicationUserManager(new UserStore <User>(dataContext)); }
public async Task <IHttpActionResult> SetMenuAsCanMadeOrder([FromBody] MenuCanBeOrderedMessageDto messageDto) { if (messageDto == null) { return(BadRequest()); } MenuForWeek menu = _weekmenuService.FindById(messageDto.WeekMenuId); menu.OrderCanBeCreated = true; _db.Entry(menu).State = EntityState.Modified; await _db.SaveChangesAsync(); ApplicationUserManager userManager = new ApplicationUserManager(new UserStore <User>(_unitOfWork.GetContext())); List <User> users = userManager.Users.ToList(); MessageService.SendEmailAsync(users, MessageTopic.MenuCreated, messageDto.DateTime); return(Ok(true)); }
public async Task <IHttpActionResult> DeleteDish([FromBody] UpdateDishDeleted updel) { ApplicationDbContext db = _unitOfWork.GetContext(); Dish delDish = db.Dishes.Find(updel.DishId); if (delDish == null) { return(NotFound()); } delDish.Deleted = updel.Deleted; db.Entry(delDish).State = EntityState.Modified; await _unitOfWork.SaveChangesAsync(); return(Ok(delDish.Deleted)); }
public static List<Dish> GetDishes(IUnitOfWorkAsync unitOfWork) { Dish[] dishArray = unitOfWork.GetContext().Dishes.ToArray(); string[] categories = MapHelper.GetCategoriesStrings(unitOfWork); Func<string, IEnumerable<Dish>, int> countDish = (str, list) => { int coun = list.Count(el => string.Equals(el.DishType.Category, str)); return coun; }; Dictionary<string, int> catCount = categories.ToDictionary(cat => cat, count => countDish(count, dishArray)); Func<List<Dish>> getDishes = () => { return catCount.Select(pair => dishArray.Where(d => string.Equals(d.DishType.Category, pair.Key)).ElementAt(Rand.Next(pair.Value))).ToList(); }; return getDishes(); }
public static List <Dish> GetDishes(IUnitOfWorkAsync unitOfWork) { Dish[] dishArray = unitOfWork.GetContext().Dishes.ToArray(); string[] categories = MapHelper.GetCategoriesStrings(unitOfWork); Func <string, IEnumerable <Dish>, int> countDish = (str, list) => { int coun = list.Count(el => string.Equals(el.DishType.Category, str)); return(coun); }; Dictionary <string, int> catCount = categories.ToDictionary(cat => cat, count => countDish(count, dishArray)); Func <List <Dish> > getDishes = () => { return(catCount.Select(pair => dishArray.Where(d => string.Equals(d.DishType.Category, pair.Key)).ElementAt(Rand.Next(pair.Value))).ToList()); }; return(getDishes()); }
public static WeekOrderDto GetMapDto(IUnitOfWorkAsync unitOfWork, WeekYearDto wyDto, bool needfact = true) { ApplicationDbContext context = unitOfWork.GetContext(); MenuForWeek menuForWeek = unitOfWork.RepositoryAsync<MenuForWeek>().GetWeekMenuByWeekYear(wyDto); if (menuForWeek == null) return null; List<WeekOrderMenu> weekOrderMenus = unitOfWork.RepositoryAsync<WeekOrderMenu>() .OrdersMenuByWeekYear(wyDto).Where(word=>word.User.IsExisting).OrderBy(wo=>wo.User.LastName).ToList(); return new WeekOrderDto { WeekYearDto = wyDto, SuCanChangeOrder = menuForWeek.SUCanChangeOrder, UserWeekOrders = weekOrderMenus.Select(woDto => UserWeekOrderDto.MapDto(context, woDto)).ToList(), DayNames = context.GetDayNames(wyDto, true).Result, WeekDishPrices = context.GetWeekDishPrices(wyDto).Result, SummaryDishQuantities = context.GetFactSumWeekUserCounts(wyDto).Result, AllDayNames = context.GetDayNames(wyDto).Result }; }
public AccountManagementApiController(IUnitOfWorkAsync unitOfWork) { _unitOfWork = unitOfWork; _userManager = new ApplicationUserManager(new UserStore <User>(_unitOfWork.GetContext())); _roleManager = new ApplicationRoleManager(new RoleStore <UserRole>(_unitOfWork.GetContext())); }
public AccountManagementApiController(IUnitOfWorkAsync unitOfWork) { _unitOfWork = unitOfWork; _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext())); _roleManager = new ApplicationRoleManager(new RoleStore<UserRole>(_unitOfWork.GetContext())); }
public async Task <double> UpdatePaiment([FromBody] UpdateWeekPaimentDto upwpDto) { double balance = _unitOfWork.GetContext().UpdateWeekPaiment(upwpDto); return(balance); }
public async Task <IHttpActionResult> UpdateAll([FromBody] UpdateAllWeekOrderDto uaDto) { _unitOfWork.GetContext().UpdateAllQuantitiesOnWeekOrder(uaDto); return(Ok(true)); }