Exemplo n.º 1
0
        private ActionResult _Index()
        {
            //set default value
            var companyRepository = _unitOfWork.RepositoryAsync <Company>();

            ViewBag.CompanySelectList = companyRepository.Queryable().Select(r => new SelectListItem {
                Text = r.Name, Value = r.Id.ToString()
            }).ToArray();

            ViewBag.RoleSelectList = RoleManager.Roles.Select(r => new SelectListItem {
                Text = r.Name, Value = r.Name
            }).ToArray();
            try
            {
                ViewBag.MaxRolesCount = UserManager.Users.Max(u => u.Roles.Count);
            }
            catch (InvalidOperationException ex)
            {
                ViewBag.MaxRolesCount = 0;
                Console.WriteLine(ex);
            }
            return(View("Index", new ManagementViewModel
            {
                Users = UserManager.Users.ToList(),
                Roles = RoleManager.Roles.ToList()
            }));
        }
        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 override async Task <InsertItemToNewCartResponse> InsertItemToNewCart(InsertItemToNewCartRequest request,
                                                                                     ServerCallContext context)
        {
            try
            {
                var cartCommander = _commandFactory.RepositoryAsync <Domain.Cart>();

                var cart = await Domain.Cart.Load()
                           .InsertItemToCart(request.ProductId.ConvertTo <Guid>(), request.Quantity)
                           .CalculateCartAsync(
                    TaxType.NoTax,
                    _catalogGateway,
                    _promoGateway,
                    _shippingGateway);

                await cartCommander.AddAsync(cart);

                return(new InsertItemToNewCartResponse {
                    Result = cart.ToDto()
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                throw new RpcException(new Status(StatusCode.Internal, ex.Message));
            }
        }
        public void CreateOREdit(dto_User entity)
        {
            this.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);

            var _GroupRepo      = _uow.RepositoryAsync <tbl_Group>();
            var _PrivilligeRepo = _uow.RepositoryAsync <tbl_Privillige>();
            var _UserRepo       = _uow.RepositoryAsync <tbl_User>();

            var Mapped = AutoMapper.Mapper.Map <tbl_User>(entity);

            Mapped.tbl_Privilligetbl_User = new List <tbl_Privilligetbl_User>();
            Mapped.tbl_Grouptbl_User      = new List <tbl_Grouptbl_User>();
            _UserRepo.AddOrUpdate(Mapped);
            _uow.SaveChanges();

            var tbl_user = _UserRepo.Queryable().Include(c => c.tbl_Grouptbl_User).ThenInclude(c => c.Group).Include(c => c.tbl_Privilligetbl_User).ThenInclude(c => c.Privillige).Where(c => c.ID == Mapped.ID).FirstOrDefault();

            tbl_user.tbl_Privilligetbl_User.RemoveAll(c => true);
            tbl_user.tbl_Privilligetbl_User.AddRange(entity.Privilliges.Select(c => new tbl_Privilligetbl_User()
            {
                tbl_Privillige_ID = c.ID, tbl_User_ID = Mapped.ID
            }));
            tbl_user.tbl_Grouptbl_User.RemoveAll(c => true);
            tbl_user.tbl_Grouptbl_User.AddRange(entity.Groups.Select(c => new tbl_Grouptbl_User()
            {
                tbl_Group_ID = c.ID, tbl_User_ID = Mapped.ID
            }));
            _UserRepo.AddOrUpdate(tbl_user);
            _uow.SaveChanges();
            this.Commit();
        }
Exemplo n.º 5
0
        public override async Task <CreateReviewResponse> CreateReview(CreateReviewRequest request,
                                                                       ServerCallContext context)
        {
            try
            {
                var reviewRepository = _commandFactory.RepositoryAsync <Domain.Review>();

                var review = Domain.Review
                             .Load(request.Content)
                             .AddAuthor(request.UserId.ConvertTo <Guid>())
                             .AddProduct(request.ProductId.ConvertTo <Guid>());

                var result = await reviewRepository.AddAsync(review);

                return(new CreateReviewResponse
                {
                    Result = result.ToDto()
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                throw new RpcException(new Status(StatusCode.Internal, ex.Message));
            }
        }
Exemplo n.º 6
0
 public WeekMenuController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork          = unitOfWork;
     _db                  = _unitOfWork.GetContext();
     _weekmenuService     = new MenuForWeekService(_unitOfWork.RepositoryAsync <MenuForWeek>());
     _mfdDishPriceService = new MfdDishPriceService(_unitOfWork.RepositoryAsync <MfdDishPriceRelations>());
 }
Exemplo n.º 7
0
 public WeekMenuController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _db = _unitOfWork.GetContext();
     _weekmenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
     _mfdDishPriceService=new MfdDishPriceService(_unitOfWork.RepositoryAsync<MfdDishPriceRelations>());
 }
Exemplo n.º 8
0
        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 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>());
 }
Exemplo n.º 11
0
        public async Task <ActionResult> GetBaseCodes()
        {
            var basecodeRepository = _unitOfWork.RepositoryAsync <BaseCode>();
            var data = await basecodeRepository.Queryable().ToListAsync();

            var rows = data.Select(n => new { Id = n.Id, CodeType = n.CodeType });

            return(Json(rows, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 12
0
        //[OutputCache(Duration = 360, VaryByParam = "none")]
        public async Task <JsonResult> GetOrders(string q = "")
        {
            var orderRepository = _unitOfWork.RepositoryAsync <Order>();
            var data            = await orderRepository.Queryable().Where(n => n.Customer.Contains(q)).ToListAsync();

            var rows = data.Select(n => new { Id = n.Id, Customer = n.Customer });

            return(Json(rows, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
        public FilePathResult GetExelFromWeekPaimentstDto([FromBody] ForExcelDataDto feDto)
        {
            WeekPaimentDto dto      = WeekPaimentDto.GetMapDto(_unitOfWork.RepositoryAsync <WeekPaiment>(), feDto.WeekYear);
            string         filename = _getExcelService.GetExcelFileFromPaimentsModel(feDto);
            string         _path    = string.Format("/ExcelFiles/{0}",
                                                    filename.Substring(filename.LastIndexOf(@"\", StringComparison.Ordinal) + 1));

            return(new FilePathResult(_path, "multipart/form-data"));
        }
Exemplo n.º 14
0
        public async Task <ActionResult> GetCategories()
        {
            var categoryRepository = _unitOfWork.RepositoryAsync <Category>();
            var data = await categoryRepository.Queryable().ToListAsync();

            var rows = data.Select(n => new { Id = n.Id, Name = n.Name });

            return(Json(rows, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 15
0
        //[OutputCache(Duration = 360, VaryByParam = "none")]
        public async Task <JsonResult> GetCompanies(string q = "")
        {
            var companyRepository = _unitOfWork.RepositoryAsync <Company>();
            var data = await companyRepository.Queryable().Where(n => n.Name.Contains(q)).ToListAsync();

            var rows = data.Select(n => new { Id = n.Id, Name = n.Name });

            return(Json(rows, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 16
0
        public async Task <IHttpActionResult> SendEmailUpdateMenu([FromBody] MenuUpdateMessageDto messageDto)
        {
            if (messageDto == null)
            {
                return(BadRequest());
            }
            MessageService.SendUpdateDayMenuMessage(_unitOfWork.RepositoryAsync <WeekOrderMenu>(), messageDto);

            return(Ok(true));
        }
Exemplo n.º 17
0
 public StripeService(IUnitOfWorkAsync unitOfWork,
                      IOptions <AppSettings> appSettings,
                      ILogger <StripeService> logger)
 {
     _appSettings      = appSettings.Value;
     _stripeSettings   = appSettings.Value.Stripe;
     _logger           = logger;
     _personRepository = unitOfWork.RepositoryAsync <Person>();
     _organizationCustomerRepository = unitOfWork.RepositoryAsync <OrganizationCustomer>();
 }
Exemplo n.º 18
0
        //GET: MenuItems/Edit/:id
        public ActionResult Edit(int id)
        {
            var menuItem = menuItemService.Find(id);

            if (menuItem == null)
            {
                return(HttpNotFound());
            }
            var menuitemRepository = unitOfWork.RepositoryAsync <MenuItem>();

            ViewBag.ParentId = new SelectList(menuitemRepository.Queryable().OrderBy(n => n.Title), "Id", "Title", menuItem.ParentId);
            return(View(menuItem));
        }
Exemplo n.º 19
0
        public DisperseFundsService(
            IUnitOfWorkAsync unitOfWork,
            IServiceProvider serviceProvider,
            ILogger <PayoutService> logger,
            FundsDispersalEventHandlers fundsEventHandlers,
            InvoicesEventHandlers handlers,
            TransferService transferService) : base(serviceProvider)
        {
            _logger                    = logger;
            _transferService           = transferService;
            _individualPayoutIntents   = unitOfWork.RepositoryAsync <IndividualPayoutIntent>();
            _organizationPayoutIntents = unitOfWork.RepositoryAsync <OrganizationPayoutIntent>();
            _transfers                 = unitOfWork.RepositoryAsync <StripeTransfer>();

            AddEventHandler(handlers, fundsEventHandlers);
        }
Exemplo n.º 20
0
    public string GetReferentie(string prefix)
    {
        IRepositoryAsync <ParameterGetal> parameterGetalRepository = _unitOfWork.RepositoryAsync <ParameterGetal>();

        Debug.Assert(parameterGetalRepository != null);
        var dateparameterGetal = parameterGetalRepository
                                 .Query(DatumExpression)
                                 .Select()
                                 .Single();
        var ordertellerparametergetal = parameterGetalRepository
                                        .Query(OrderTellerExpression)
                                        .Select()
                                        .Single();
        DateTime date        = DateTime.Parse(dateparameterGetal.parameterwaarde);
        int      orderteller = 0;

        if (date == DateTime.Today)
        {
            orderteller = int.Parse(ordertellerparametergetal.parameterwaarde);
        }
        else
        {
            dateparameterGetal.parameterwaarde = string.Format("{0:dd/MM/yyyy}", DateTime.Today);
            orderteller = 0;
        }
        orderteller++;
        ordertellerparametergetal.parameterwaarde = orderteller.ToString();
        string result = string.Format("{0}{1:yyyyMMdd}.{2:00}", prefix, DateTime.Today, orderteller);

        return(result);
    }
Exemplo n.º 21
0
        private IQueryable <T> GetReportSouce <T>() where T : Entity
        {
            var repository = _unitOfWork.RepositoryAsync <T>();
            var source     = repository.Queryable();

            return(source);
        }
Exemplo n.º 22
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()));
 }
Exemplo n.º 23
0
 public Service(IUnitOfWorkAsync unitOfWork)
 {
     UnitOfWork    = unitOfWork;
     Repository    = UnitOfWork.RepositoryAsync <TEntity>();
     EventsHandler = new EventsHandler();
     Module        = typeof(TEntity).Name;
 }
Exemplo n.º 24
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()));
 }
Exemplo n.º 25
0
        public override async Task <CreateReviewResponse> CreateReview(CreateReviewRequest request,
                                                                       ServerCallContext context)
        {
            var reviewRepository = _commandFactory.RepositoryAsync <Domain.Review>();

            var review = Domain.Review
                         .Load(request.Content)
                         .AddAuthor(request.UserId.ConvertTo <Guid>())
                         .AddProduct(request.ProductId.ConvertTo <Guid>());

            var result = await reviewRepository.AddAsync(review);

            return(new CreateReviewResponse
            {
                Result = result.ToDto()
            });
        }
Exemplo n.º 26
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));
 }
Exemplo n.º 27
0
        public void TestInitialize()
        {
            _ninjaClanFakeContext = new NinjaClanFakeContext();
            _unitOfWorkAsync      = new UnitOfWork(_ninjaClanFakeContext);
            _ninjaClanRepository  = _unitOfWorkAsync.RepositoryAsync <NinjaClan>();

            CreateClans();
        }
Exemplo n.º 28
0
 public BaseManager(IUnitOfWorkAsync unitOfWorkAsync)
 {
     dbContext        = new ApplicationDbContext();
     _unitOfWorkAsync = unitOfWorkAsync;
     issueService     = new IsssueService(unitOfWorkAsync.RepositoryAsync <WorkIssue>());
     //jobService = new JobService(unitOfWorkAsync.RepositoryAsync<Job>());
     emailService = new EmailService();
 }
Exemplo n.º 29
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));
        }
Exemplo n.º 30
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));
        }
Exemplo n.º 31
0
        /// <summary>
        /// Получить массив категорий блюд
        /// </summary>
        /// <param name="unitOfWorkAsync"></param>
        /// <returns></returns>
        public static string[] GetCategoriesStrings(IUnitOfWorkAsync unitOfWorkAsync)
        {
            var cats = unitOfWorkAsync.RepositoryAsync <DishType>();

            string[] categories = cats.Queryable()
                                  .Select(dt => dt.Category)
                                  .AsQueryable()
                                  .ToArrayAsync().Result;
            return(categories);
        }
Exemplo n.º 32
0
        public override async Task <InsertItemToNewCartResponse> InsertItemToNewCart(InsertItemToNewCartRequest request,
                                                                                     ServerCallContext context)
        {
            var cartCommander = _commandFactory.RepositoryAsync <Domain.Cart>();

            var cart = await Domain.Cart.Load()
                       .InsertItemToCart(request.ProductId.ConvertTo <Guid>(), request.Quantity)
                       .CalculateCartAsync(
                TaxType.NoTax,
                _catalogGateway,
                _promoGateway,
                _shippingGateway);

            await cartCommander.AddAsync(cart);

            return(new InsertItemToNewCartResponse {
                Result = cart.ToDto()
            });
        }
        public async Task <CreateProjectResponse> Handle(CreateProjectRequest request,
                                                         CancellationToken cancellationToken)
        {
            var projectRepository = _uow.RepositoryAsync <Domain.Project>();

            var result = await projectRepository.AddAsync(Domain.Project.Load(request.Name));

            return(new CreateProjectResponse {
                Result = result.ToDto()
            });
        }
Exemplo n.º 34
0
        public async Task <WeekPaimentDto> GetWeekPaiments([FromBody] WeekYearDto wyDto)
        {
            if (wyDto == null)
            {
                wyDto = YearWeekHelp.GetCurrentWeekYearDto();
            }

            WeekPaimentDto dto = WeekPaimentDto.GetMapDto(_unitOfWork.RepositoryAsync <WeekPaiment>(), wyDto);

            return(await Task.FromResult(dto));
        }
Exemplo n.º 35
0
        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
            };
        }
Exemplo n.º 36
0
 public AccountController(IUnitOfWorkAsync unitOfWork)
 {
     //This is temproray solution, for issue on DB create if it does not exists.
     var a = unitOfWork.RepositoryAsync<AspNetUser>().Query().Select(x => x).FirstOrDefault();
     UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
 }
Exemplo n.º 37
0
 public GetExcelController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _getExcelService = new GetExcelService(_unitOfWork.RepositoryAsync<WeekOrderMenu>());
     _menuForWeekService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
 }
Exemplo n.º 38
0
 public DiagnosesService(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _dignosisRepo = unitOfWork.RepositoryAsync<Diagnosis>();
     _dignosisSymptomRepo = unitOfWork.RepositoryAsync<DiagnosisSymptom>();
 }
Exemplo n.º 39
0
 public DishesController(IUnitOfWorkAsync unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _mfdDishPriceService = new MfdDishPriceService(_unitOfWork.RepositoryAsync<MfdDishPriceRelations>());
 }
Exemplo n.º 40
0
 public PaimentController(IUnitOfWorkAsync unitOfWorkAsync)
 {
     _unitOfWork = unitOfWorkAsync;
     //_db = unitOfWorkAsync.GetContext();
     _weekPaimentService = new WeekPaimentService(_unitOfWork.RepositoryAsync<WeekPaiment>());
 }