コード例 #1
0
 public TestWeekMenuController()
 {
     _unitOfWork      = new UnitOfWork(new ApplicationDbContext());
     _db              = _unitOfWork.GetContext();
     _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync <MenuForWeek>());
     _userManager     = new ApplicationUserManager(new UserStore <User>(_unitOfWork.GetContext()));
 }
コード例 #2
0
        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));
        }
コード例 #3
0
 public TestWeekMenuController()
 {
     _unitOfWork = new UnitOfWork(new ApplicationDbContext());
     _db = _unitOfWork.GetContext();
     _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
     _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext()));
 }
コード例 #4
0
        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));
        }
コード例 #5
0
ファイル: WeekOrderDto.cs プロジェクト: densem-2013/ACSDining
        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
            });
        }
コード例 #6
0
 public WeekMenuController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork          = unitOfWork;
     _db                  = _unitOfWork.GetContext();
     _weekmenuService     = new MenuForWeekService(_unitOfWork.RepositoryAsync <MenuForWeek>());
     _mfdDishPriceService = new MfdDishPriceService(_unitOfWork.RepositoryAsync <MfdDishPriceRelations>());
 }
コード例 #7
0
 public WeekMenuController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _db = _unitOfWork.GetContext();
     _weekmenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
     _mfdDishPriceService=new MfdDishPriceService(_unitOfWork.RepositoryAsync<MfdDishPriceRelations>());
 }
コード例 #8
0
        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));
        }
コード例 #9
0
 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>());
 }
コード例 #10
0
 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>());
 }
コード例 #11
0
 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));
 }
コード例 #12
0
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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));
        }
コード例 #15
0
ファイル: TestHelper.cs プロジェクト: densem-2013/ACSDining
        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();
        }
コード例 #16
0
        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());
        }
コード例 #17
0
ファイル: WeekOrderDto.cs プロジェクト: densem-2013/ACSDining
        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
            };
        }
コード例 #18
0
 public AccountManagementApiController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork  = unitOfWork;
     _userManager = new ApplicationUserManager(new UserStore <User>(_unitOfWork.GetContext()));
     _roleManager = new ApplicationRoleManager(new RoleStore <UserRole>(_unitOfWork.GetContext()));
 }
コード例 #19
0
 public AccountManagementApiController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext()));
     _roleManager = new ApplicationRoleManager(new RoleStore<UserRole>(_unitOfWork.GetContext()));
 }
コード例 #20
0
        public async Task <double> UpdatePaiment([FromBody] UpdateWeekPaimentDto upwpDto)
        {
            double balance = _unitOfWork.GetContext().UpdateWeekPaiment(upwpDto);

            return(balance);
        }
コード例 #21
0
        public async Task <IHttpActionResult> UpdateAll([FromBody] UpdateAllWeekOrderDto uaDto)
        {
            _unitOfWork.GetContext().UpdateAllQuantitiesOnWeekOrder(uaDto);

            return(Ok(true));
        }