コード例 #1
0
        public async Task <IActionResult> ProductAvalibalityChange(int productId)
        {
            LocalItem localItem = await db.LocalItems.SingleOrDefaultAsync(p => p.BasicItem.Id == productId);

            if (localItem == null)
            {
                Item item = await db.Items.SingleOrDefaultAsync(p => p.Id == productId);

                if (item != null)
                {
                    localItem = new LocalItem {
                        BasicItem = item, IsAvalible = true
                    };
                    db.LocalItems.Add(localItem);
                }
            }
            else
            {
                localItem.IsAvalible = !localItem.IsAvalible;
            }
            await db.SaveChangesAsync();

            await logger.AddToLogAsync($"Changed avalibality on product ID:{productId} to {localItem.IsAvalible}");

            return(RedirectToAction("Products"));
        }
コード例 #2
0
        public async Task <IActionResult> AddSingleItem(Storage model)
        {
            var storage = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new storage (Id: {storage.Id}).");

            return(RedirectToRoute(StoragesRouting.Index));
        }
コード例 #3
0
        public async Task <IActionResult> AddSingleItem(ProductCatalog model)
        {
            var product = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new product into catalog (Id: {product.Id}).");

            return(RedirectToRoute(ProductsCatalogRouting.Index));
        }
コード例 #4
0
        public async Task <IActionResult> AddSingleItem(TechProcess model)
        {
            var techProcess = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new technological process (Facility Id: {techProcess.FacilityId}; Recipe Id: {techProcess.RecipeId}).");

            return(RedirectToRoute(FacilityTechProcessesRouting.Index, new { key = model.FacilityId }));
        }
コード例 #5
0
ファイル: OperationsController.cs プロジェクト: No0zZy/Cursed
        public async Task <IActionResult> AddSingleItem(Operation model)
        {
            var operation = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new operation (Id: {operation.Id}).");

            return(RedirectToRoute(TransactionsRouting.SingleItem, new { key = model.TransactionId }));
        }
コード例 #6
0
        public async Task <IActionResult> AddSingleItem(Facility model)
        {
            var facility = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new facility (Id: {facility.Id}).");

            return(RedirectToRoute(FacilitiesRouting.Index));
        }
コード例 #7
0
ファイル: LicensesController.cs プロジェクト: No0zZy/Cursed
        public async Task <IActionResult> AddSingleItem(License model)
        {
            var license = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new license (Id: {license.Id}).");

            return(RedirectToRoute(LicensesRouting.Index));
        }
コード例 #8
0
ファイル: CompaniesController.cs プロジェクト: No0zZy/Cursed
        public async Task <IActionResult> AddSingleItem(Company model)
        {
            var company = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new company (Id: {company.Id}).");

            return(RedirectToRoute(CompaniesRouting.Index));
        }
コード例 #9
0
        public async Task <IActionResult> AddSingleItem(RecipeProductChanges model)
        {
            var recipeProductChanges = await logic.AddDataModelAsync(model);

            await logProvider.AddToLogAsync($"Added new recipe product relations (Recipe Id: {recipeProductChanges.RecipeId}; Product Id: {recipeProductChanges.ProductId}).");

            return(RedirectToRoute(RecipeProductsRouting.Index, new { key = model.RecipeId }));
        }
コード例 #10
0
        public async Task <IActionResult> DeleteProductFromCategory(int productId, int categoryId)
        {
            ItemToCategory itemToCategory = await db.ItemsToCategories.SingleOrDefaultAsync(p => (p.ItemId == productId) && (p.CategoryId == categoryId));

            if (itemToCategory != null)
            {
                db.ItemsToCategories.Remove(itemToCategory);
                await db.SaveChangesAsync();

                await logger.AddToLogAsync($"Product ID:{itemToCategory.ItemId} deleted from category ID:{itemToCategory.CategoryId}");
            }
            return(RedirectToRoute("AdminSelectToAddToCategory", new { categoryId }));
        }
コード例 #11
0
ファイル: HubController.cs プロジェクト: No0zZy/Cursed
        public async Task <IActionResult> Error()
        {
            var feature = HttpContext.Features.Get <IExceptionHandlerPathFeature>();

            // feature is not null, when action accessed through exception handling redirection
            if (feature != null)
            {
                // gather exception
                var exception      = feature.Error;
                var exceptionInner = exception.InnerException;

                // form a message
                var exceptionMessage = new StringBuilder("Error occured\n:");
                exceptionMessage.Append($"Stack trace: {exception.StackTrace}\n");
                exceptionMessage.Append($"Message: {exception.Message}\n");

                while (exceptionInner != null)
                {
                    exceptionMessage.Append($"Stack trace: {exceptionInner.StackTrace}\n");
                    exceptionMessage.Append($"Message: {exceptionInner.Message}\n");
                    exceptionInner = exceptionInner.InnerException;
                }

                // log exception message
                await logProvider.AddToLogAsync(exceptionMessage.ToString());
            }
            return(View());
        }
コード例 #12
0
        public async Task <IActionResult> AddSingleItem(RegistrationModel model)
        {
            var statusMessage = await logicValidation.CheckAddSingleDataModelAsync(model.Login, model.RoleName);

            if (statusMessage.IsCompleted)
            {
                var user = await logic.AddDataModelAsync(model);

                await logProvider.AddToLogAsync($"Added new user (Login: {user.Login}).");

                return(RedirectToRoute(UserManagmentRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }
コード例 #13
0
        public async Task <IActionResult> AddSingleItem(License model)
        {
            var statusMessage = await logicValidation.CheckAddDataModelAsync(model);

            if (statusMessage.IsCompleted)
            {
                var license = await logic.AddDataModelAsync(model);

                await logProvider.AddToLogAsync($"Added new license (Id: {license.Id}).");

                return(RedirectToRoute(LicensesRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }
コード例 #14
0
        public async Task <IActionResult> AddSingleItem(RecipeProductChanges model)
        {
            var recipeProductChanges = await logic.AddDataModelAsync(model);

            var statusMessage = logicValidation.ValidateModel(ModelState);

            if (statusMessage.IsCompleted)
            {
                await logProvider.AddToLogAsync($"Added new recipe product relations (Recipe Id: {recipeProductChanges.RecipeId}; Product Id: {recipeProductChanges.ProductId}).");

                return(RedirectToRoute(RecipeProductsRouting.Index, new { key = model.RecipeId }));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }
コード例 #15
0
ファイル: OperationsController.cs プロジェクト: 42ama/Cursed
        public async Task <IActionResult> AddSingleItem(Operation model)
        {
            var statusMessage = await logicValidation.CheckAddDataModelAsync(model);

            logicValidation.ValidateModel(statusMessage, ModelState);
            if (statusMessage.IsCompleted)
            {
                var operation = await logic.AddDataModelAsync(model);

                await logProvider.AddToLogAsync($"Added new operation (Id: {operation.Id}).");

                return(RedirectToRoute(TransactionsRouting.SingleItem, new { key = model.TransactionId }));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }
コード例 #16
0
        public async Task <IActionResult> CloseTransaction(string key)
        {
            int id            = Int32.Parse(key);
            var statusMessage = await logicValidation.CheckCloseTransactionAsync(id);

            if (statusMessage.IsCompleted)
            {
                await logic.CloseTransactionAsync(id);

                await logProvider.AddToLogAsync($"Closed transaction (Id: {key}).");

                return(RedirectToRoute(TransactionsRouting.SingleItem, new { key }));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }
コード例 #17
0
        public async Task <IActionResult> AddSingleItem(TechProcess model)
        {
            var statusMessage = await logicValidation.CheckAddDataModelAsync(model);

            statusMessage = logicValidation.ValidateModel(statusMessage, ModelState);
            if (statusMessage.IsCompleted)
            {
                var techProcess = await logic.AddDataModelAsync(model);

                await logProvider.AddToLogAsync($"Added new technological process (Facility Id: {techProcess.FacilityId}; Recipe Id: {techProcess.RecipeId}).");

                return(RedirectToRoute(FacilityTechProcessesRouting.Index, new { key = model.FacilityId }));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }
コード例 #18
0
        public async Task <IActionResult> Delete(int accountId)
        {
            AdministratorUser user = await db.AdministratorUsers.SingleOrDefaultAsync(p => p.Id == accountId);

            if (user.Tier >= maxTier)
            {
                int maxTierUsers = await db.AdministratorUsers.Where(p => p.Tier >= maxTier).CountAsync();

                if (maxTierUsers <= minimumMaxTierUsers)
                {
                    return(RedirectToRoute("ErrorMessage", new { Message = $"Total number of users with Tier >= {maxTier} must be higher or equal to {minimumMaxTierUsers} after delete.", RedirectRoute = "AdminAccounts" }));
                }
            }
            db.AdministratorUsers.Remove(user);
            await db.SaveChangesAsync();

            await logger.AddToLogAsync($"Deleted account ID:{accountId}");

            return(RedirectToAction("Accounts"));
        }
コード例 #19
0
        public async Task <IActionResult> Login(LoginModel loginModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(loginModel));
            }

            var statusMessage = await logicValidation.CheckLogin(loginModel);

            if (statusMessage.IsCompleted)
            {
                var userData = await logic.GetUserData(loginModel.Login);
                await Authenticate(userData.Login, userData.RoleName);

                await logProvider.AddToLogAsync("User logged in.", loginModel.Login);

                return(RedirectToRoute(HubRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }