Beispiel #1
0
        public async Task <IActionResult> PutEmployeeWorkHour(Guid id, EmployeeWorkHour employeeWorkHour)
        {
            if (id != employeeWorkHour.WorkHourId)
            {
                return(BadRequest());
            }

            _context.Entry(employeeWorkHour).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeWorkHourExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <ActionResult <OrderProduct> > PostOrderProduct(OrderProduct orderProduct)
        {
            _context.OrderProducts.Add(orderProduct);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrderProduct", new { id = orderProduct.OrderProductId }, orderProduct));
        }
Beispiel #3
0
        public async Task <ActionResult <User> > PostUser(User user)
        {
            _context.Users.Add(user);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUser", new { id = user.UserId }, user));
        }
Beispiel #4
0
        public async Task <IActionResult> PutStoreLicense(Guid id, StoreLicense storeLicense)
        {
            if (id != storeLicense.LicenseId)
            {
                return(BadRequest());
            }

            _context.Entry(storeLicense).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreLicenseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #5
0
        public async Task <ActionResult <Order> > PostOrder(Order order)
        {
            _context.Orders.Add(order);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrder", new { id = order.OrderId }, order));
        }
        public async Task <ActionResult <Employee> > PostEmployee(Employee employee)
        {
            _context.Employees.Add(employee);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEmployee", new { id = employee.EmployeeId }, employee));
        }
        public async Task <ActionResult <Product> > PostProduct(Product product)
        {
            _context.Products.Add(product);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProduct", new { id = product.ProductId }, product));
        }
        public async Task <ActionResult <UserRequest> > PostUserRequest(UserRequest userRequest)
        {
            _context.Requests.Add(userRequest);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUserRequest", new { id = userRequest.RequestId }, userRequest));
        }
Beispiel #9
0
        public async Task <IActionResult> PutPaymentCard(Guid id, PaymentCard paymentCard)
        {
            if (id != paymentCard.PaymentCardId)
            {
                return(BadRequest());
            }

            _context.Entry(paymentCard).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PaymentCardExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #10
0
        public async Task <IActionResult> PutSubcription(string id, Subcription subcription)
        {
            if (id != subcription.StripeSubCriptionID)
            {
                return(BadRequest());
            }

            _context.Entry(subcription).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubcriptionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #11
0
        public async Task <ActionResult <bool> > PutOrder(Order orderupdated)
        {
            _context.Entry(orderupdated).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();



                if (orderupdated.OrderStatus == Status.Submited)
                {
                    foreach (var item in orderupdated.OrderProducts)
                    {
                        var product = _context.Products.Where(p => p.StoreId == item.StoreId && p.ProductId == item.ProductIdReference).FirstOrDefault();

                        if (product != null && product.InventoryQuantity > 0)
                        {
                            product.InventoryQuantity -= item.Quantity;

                            _context.Entry(product).State = EntityState.Modified;

                            await _context.SaveChangesAsync();
                        }
                    }
                }

                //_context.SaveChanges();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderExists(orderupdated.OrderId))
                {
                    return(NotFound());
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #12
0
        public async Task <bool> PutStore(Store store)
        {
            try
            {
                _context.Entry(store).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                var result = _context.WorkHours.Where(w => w.StoreId == store.StoreId).ToList();

                _context.WorkHours.RemoveRange(result);

                await _context.SaveChangesAsync();

                _context.WorkHours.AddRange(store.WorkHours);

                await _context.SaveChangesAsync();


                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreExists(store.StoreId))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
        }
        public async Task <bool> PutWorkHour(WorkHour workHour)
        {
            _context.Entry(workHour).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkHourExists(workHour.WorkHourId))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
        }
        public async Task <bool> PutStoreLicense(StoreLicense storeLicense)
        {
            _context.Entry(storeLicense).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreLicenseExists(storeLicense.LicenseId))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #15
0
        public async Task <ActionResult <bool> > PutUsersConnected(UsersConnected usersConnected)
        {
            _context.Entry(usersConnected).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsersConnectedExists(usersConnected.HubConnectionID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #16
0
        public async Task <ActionResult <bool> > ValidateEmail(string code, string userid)
        {
            var validate = await _context.EmailValidations.Where(email => email.ValidationCode == code && email.UserId.ToString() == userid && DateTime.Now <= email.ExpDate).FirstOrDefaultAsync();


            if (validate != null)
            {
                var user = await _context.Users.Where(u => u.UserId.ToString() == userid).FirstOrDefaultAsync();

                user.IsValidUser = true;

                _context.Entry(user).State = EntityState.Modified;

                await _context.SaveChangesAsync();

                return(true);
            }

            return(false);
        }