Example #1
0
        public async Task <int> CreateAsync(CreateFabricCommand command)
        {
            var producer = await _context.Producers.FirstOrDefaultAsync(x => x.Id == command.ProducerId);

            if (producer == null)
            {
                throw new GfsException(ErrorCode.ProducerNotFound, _dictionary.ProducerNotFound);
            }

            var fabric = new Fabric
            {
                Thickness    = command.Thickness,
                Name         = command.Name,
                ImageUrl     = command.ImageUrl,
                ProducerCode = command.ProducerCode,
                Producer     = producer,
                ProducerId   = command.ProducerId
            };

            await _context.Fabrics.AddAsync(fabric);

            await _context.SaveChangesAsync();

            return(fabric.Id);
        }
        public async Task <int> CreateAsync(CreateProducerCommand command)
        {
            var producer = new Producer
            {
                Name        = command.Name,
                Street      = command.Street,
                City        = command.City,
                Email       = command.Email,
                PhoneNumber = command.PhoneNumber
            };

            await _context.Producers.AddAsync(producer);

            await _context.SaveChangesAsync();

            return(producer.Id);
        }
Example #3
0
        public async Task <int> CreateAsync(CreateOrderCommand command)
        {
            var user = await _context.Users.FirstOrDefaultAsync(x => x.Id == command.UserId);

            if (user == null)
            {
                throw new GfsException(ErrorCode.UserNotFound, _dictionary.UserNotFound);
            }

            var order = new Order
            {
                Description = command.Description,
                Date        = DateTime.Now,
                IsConfirmed = false,
                User        = user,
                UserId      = command.UserId
            };
            await _context.Orders.AddAsync(order);

            await _context.SaveChangesAsync();

            return(order.Id);
        }
Example #4
0
        public async Task CreateVersaliteDrawersAsync(float width, float depth, float frontHeight, float drawerHeight,
                                                      Fabric corpusFabric, Fabric frontFabric, int count, Furniture furniture)
        {
            await _context.RectangularFormatters.AddAsync(new RectangularFormatter
            {
                Name                = "BOK LEWY SZUFLADY",
                Count               = count,
                IsMilling           = false,
                Width               = depth - 20,
                Length              = drawerHeight,
                Thickness           = corpusFabric.Thickness,
                Furniture           = furniture,
                FurnitureId         = furniture.Id,
                Fabric              = corpusFabric,
                FabricId            = corpusFabric.Id,
                IsTopBorder         = false,
                IsBottomBorder      = false,
                IsRightBorder       = false,
                IsLeftBorder        = true,
                LeftBorderThickness = 1
            });

            await _context.RectangularFormatters.AddAsync(new RectangularFormatter
            {
                Name                 = "BOK PRAWY SZUFLADY",
                Count                = count,
                IsMilling            = false,
                Width                = depth - 20,
                Length               = drawerHeight,
                Thickness            = corpusFabric.Thickness,
                Furniture            = furniture,
                FurnitureId          = furniture.Id,
                Fabric               = corpusFabric,
                FabricId             = corpusFabric.Id,
                IsTopBorder          = false,
                IsBottomBorder       = false,
                IsRightBorder        = true,
                IsLeftBorder         = false,
                RightBorderThickness = 1
            });

            await _context.RectangularFormatters.AddAsync(new RectangularFormatter
            {
                Name                = "PRZÓD SZUFLADY",
                Count               = count,
                IsMilling           = false,
                Width               = width - 2 * corpusFabric.Thickness - 27 - 2 * corpusFabric.Thickness,
                Length              = drawerHeight,
                Thickness           = corpusFabric.Thickness,
                Furniture           = furniture,
                FurnitureId         = furniture.Id,
                Fabric              = corpusFabric,
                FabricId            = corpusFabric.Id,
                IsTopBorder         = false,
                IsBottomBorder      = false,
                IsRightBorder       = false,
                IsLeftBorder        = true,
                LeftBorderThickness = 1
            });

            await _context.RectangularFormatters.AddAsync(new RectangularFormatter
            {
                Name                 = "TYŁ SZUFLADY",
                Count                = count,
                IsMilling            = false,
                Width                = width - 2 * corpusFabric.Thickness - 27 - 2 * corpusFabric.Thickness,
                Length               = drawerHeight,
                Thickness            = corpusFabric.Thickness,
                Furniture            = furniture,
                FurnitureId          = furniture.Id,
                Fabric               = corpusFabric,
                FabricId             = corpusFabric.Id,
                IsTopBorder          = false,
                IsBottomBorder       = false,
                IsRightBorder        = true,
                IsLeftBorder         = false,
                RightBorderThickness = 1
            });

            await _context.RectangularFormatters.AddAsync(new RectangularFormatter
            {
                Name           = "DNO SZUFLADY",
                Count          = count,
                IsMilling      = false,
                Width          = width - 2 * corpusFabric.Thickness - 27,
                Length         = depth - 20,
                Thickness      = corpusFabric.Thickness,
                Furniture      = furniture,
                FurnitureId    = furniture.Id,
                Fabric         = corpusFabric,
                FabricId       = corpusFabric.Id,
                IsTopBorder    = false,
                IsBottomBorder = false,
                IsRightBorder  = false,
                IsLeftBorder   = false
            });

            await _context.RectangularFormatters.AddAsync(new RectangularFormatter
            {
                Name                  = "FRONT SZUFLADY",
                Count                 = count,
                IsMilling             = false,
                Width                 = width - 4,
                Length                = frontHeight,
                Thickness             = corpusFabric.Thickness,
                Furniture             = furniture,
                FurnitureId           = furniture.Id,
                Fabric                = frontFabric,
                FabricId              = frontFabric.Id,
                IsTopBorder           = true,
                IsBottomBorder        = true,
                IsLeftBorder          = true,
                IsRightBorder         = true,
                TopBorderThickness    = 1,
                BottomBorderThickness = 1,
                LeftBorderThickness   = 1,
                RightBorderThickness  = 1
            });

            await _context.SaveChangesAsync();
        }
Example #5
0
        public async Task UpdateAsync(UpdateUserCommand command)
        {
            var user = await _context.Users.FirstOrDefaultAsync(x => x.Id == command.Id);

            if (user == null)
            {
                throw new GfsException(ErrorCode.UserNotFound, _dictionary.UserNotFound);
            }

            if (command.Name != null && command.Name != user.Name)
            {
                user.Name = command.Name;
            }
            if (command.Surname != null && command.Surname != user.Surname)
            {
                user.Surname = command.Surname;
            }

            await _context.SaveChangesAsync();
        }