Beispiel #1
0
        public async Task SetPlanning(PlanningModel planningModel)
        {
            using (var context = dbFactory.CreateDbContext())
            {
                var shoppingItem = context.ShoppingItems.SingleOrDefault(a => a.ArticleId == planningModel.ArticleId);

                if (shoppingItem == null && planningModel.Quantity != 0)
                {
                    // Insert
                    shoppingItem = planningModel.ToShoppingItem();
                    context.Add(shoppingItem);
                    await context.SaveChangesAsync();

                    return;
                }

                if (shoppingItem != null)
                {
                    if (planningModel.Quantity != 0)
                    {
                        // Update
                        shoppingItem.Quantity = planningModel.Quantity;
                        shoppingItem.PickTime = null;
                    }
                    else
                    {
                        // Delete
                        context.Remove(shoppingItem);
                    }
                    await context.SaveChangesAsync();
                }
            }
        }
        public async void Task_CarregarAlunosMock_NotFoundResult()
        {
            //Arrange
            var           controller = new PlanejamentoController(_db);
            PlanningModel model      = new PlanningModel();
            //Act
            var resulTask = await controller.CarregarAlunosMock(model);

            //Assert
            Assert.IsType <NotFoundResult>(resulTask.Result);
        }
        public async void Task_Sondagem_NotFoundResult()
        {
            //Arrange
            var           controller = new PlanejamentoController(_db);
            PlanningModel model      = new PlanningModel();
            //Act
            ActionResult <string> resulTask = await controller.CarregarAlunosSondagem(model);

            //Assert
            Assert.IsType <NotFoundResult>(resulTask.Result);
        }
        public async void Task_AbrirPlanoAnual_NotFoundResult()
        {
            //Arrange
            var           controller = new PlanejamentoController(_db);
            PlanningModel model      = new PlanningModel();
            //Act
            var resulTask = await controller.AbrirPlanoAnual(model);

            //Assert
            Assert.IsType <NotFoundResult>(resulTask.Result);
        }
Beispiel #5
0
        private void reCalculateProduction(Item item, int superItemProduction, int superItemProductionInQueue, PlanningModel changeModel)
        {
            var isInList        = false;
            var id              = item.id;
            int ordersInQueue   = getOrdersInQueue(id);
            int ordersInProcess = getOrdersInProcess(id);
            int safetyStock     = 100;

            if (allChangesForSecurityStock != null && allChangesForSecurityStock.ContainsKey(id))
            {
                int i;
                if (allChangesForSecurityStock.TryGetValue(id, out i))
                {
                    safetyStock = allChangesForSecurityStock[id];
                }
            }
            int plannedAmount = (superItemProduction * item.need) + superItemProductionInQueue;

            if (id == 1 || id == 2 || id == 3)
            {
                foreach (var i in exportModel.sellwishList)
                {
                    if (id == i.article)
                    {
                        plannedAmount = i.quantity;
                    }
                }
            }
            int           amount  = getAmount(id);
            PlanningModel addItem = calculateProductionOrder(new PlanningModel(id, plannedAmount, safetyStock, amount, ordersInQueue, ordersInProcess, 0));

            if (allProduceArticle.Contains(id))
            {
                foreach (PlanningModel i in AllItemsInTheTable)
                {
                    if (i.ID == id)
                    {
                        isInList          = true;
                        i.plannedAmount   = i.plannedAmount + addItem.plannedAmount;
                        i.productionOrder = i.productionOrder + addItem.plannedAmount;
                    }
                }
                if (!isInList)
                {
                    AllItemsInTheTable.Add(addItem);
                }
            }
            item.item.ForEach(i => reCalculateProduction(i, addItem.productionOrder, addItem.ordersInQueue, changeModel));
        }
Beispiel #6
0
        public static PlanningModel[] GetProjectPlanings(int projectId)
        {
            var list     = new List <PlanningModel>();
            var basePath = $"/Images/{projectId}/Planing";

            var localPath = HttpContext.Current.Server.MapPath(basePath);

            if (Directory.Exists(localPath))
            {
                var files = Directory.GetFiles(localPath, "*.jpg", SearchOption.TopDirectoryOnly);
                var model = new PlanningModel()
                {
                    Name = "Вариант #1"
                };
                foreach (var file in files)
                {
                    var path = basePath + "/" + Path.GetFileName(file);
                    model.Images.Add(new SampleImageModel()
                    {
                        Name = path, Comment = GetProjectComment(projectId, ProjectCommentType.Planning)
                    });
                }
                list.Add(model);

                var i       = 2;
                var subDirs = Directory.GetDirectories(localPath);
                foreach (var dir in subDirs)
                {
                    var subfiles = Directory.GetFiles(dir, "*.jpg", SearchOption.TopDirectoryOnly);
                    var submodel = new PlanningModel()
                    {
                        Name = "Вариант #" + i
                    };
                    foreach (var file in subfiles)
                    {
                        var path = basePath + "/" + Path.GetFileName(dir) + "/" + Path.GetFileName(file);
                        submodel.Images.Add(new SampleImageModel()
                        {
                            Name = path, Comment = GetProjectComment(projectId, ProjectCommentType.Planning)
                        });
                    }
                    list.Add(submodel);

                    i++;
                }
            }

            return(list.ToArray());
        }
Beispiel #7
0
        public async Task <PlanningModel> GetUserBalance(WebUser user, bool showAll = true)
        {
            var model = new PlanningModel()
            {
                Balances = new List <BalanceModel>()
            };
            IEnumerable <Category> categories = new List <Category>();

            if (showAll)
            {
                categories = (await _categoryService.GetActiveGategoriesByUser(user.Id)).ToList();
            }
            else
            {
                categories = (await _categoryService.GetActiveGategoriesByUser(user.Id)).Where(x => x.ViewInPlan == true).ToList();
            }


            model.CategoryPlanItemsIncome = categories.Where(x => x.TypeOfFlowID == 1).OrderBy(x => x.Name).ToList();
            model.CategoryPlanItemsOutgo  = categories.Where(x => x.TypeOfFlowID == 2).OrderBy(x => x.Name).ToList();

            var planItems = (await _planItemService.GetListAsync(x => x.UserId == user.Id))
                            .Where(x => x.Closed == false).ToList();

            model.Months = planItems
                           .GroupBy(x => x.Month.ToString("Y", CultureInfo.CurrentCulture))
                           .Select(x => x.Key)
                           .ToList();

            model.PlanItemsIncomePlan = model.CategoryPlanItemsIncome.Any() ? model.CategoryPlanItemsIncome.First().PlanItems.Where(x => x.Closed == false).ToList()
                : null;
            model.PlanItemsOutgoPlan = model.CategoryPlanItemsOutgo.Any() ? model.CategoryPlanItemsOutgo.First().PlanItems.Where(x => x.Closed == false).ToList()
                : null;

            var months = planItems
                         .Select(x => x.Month.Month)
                         .Distinct()
                         .ToList();

            foreach (var month in months)
            {
                var balance = GetBalanceModel(month, planItems);
                model.Balances.Add(balance);
            }

            return(model);
        }
        [Fact]//TODO: fazer ajustes Task_AbrirPlanoAnual_OkObjectResult
        public async void Task_AbrirPlanoAnual_OkObjectResult()
        {
            //Arrange
            _db = new SMEContext(dbContextOptions);
            var           controller = new PlanejamentoController(_db);
            PlanningModel model      = new PlanningModel();

            model.Username  = "";
            model.School    = "";
            model.Year      = DateTime.Now.Year;
            model.Classroom = "";
            //Act
            var resulTask = await controller.AbrirPlanoAnual(model);

            //Assert
            Assert.IsType <OkObjectResult>(resulTask.Result);
        }
Beispiel #9
0
        public static ShoppingItem ToShoppingItem(this PlanningModel planningModel)
        {
            return(new ShoppingItem
            {
                Id = Guid.NewGuid(),
                ArticleId = planningModel.ArticleId,
                ArticleName = planningModel.ArticleName,
                ArticleUnit = planningModel.ArticleUnit,
                ArticleOrder = planningModel.ArticleOrder,

                SectionId = planningModel.SectionId,
                SectionName = planningModel.SectionName,
                SectionOrder = planningModel.SectionOrder,

                Quantity = planningModel.Quantity
            });
        }
Beispiel #10
0
        private PlanningModel calculateProductionOrder(PlanningModel addItem)
        {
            var tempVal = addItem.plannedAmount + addItem.safetyStock - addItem.stockPreviousPeriod - addItem.ordersInQueue - addItem.ordersInProcess;

            if (addItem.ID == 1 || addItem.ID == 2 || addItem.ID == 3)
            {
                var directSells = exportModel.sellDirectList;
                directSells.ForEach(d =>
                {
                    if (d.article == addItem.ID)
                    {
                        tempVal += d.quantity;
                    }
                });
            }
            if (tempVal < 0)
            {
                tempVal = 0;
            }

            addItem.productionOrder = tempVal;
            return(addItem);
        }
Beispiel #11
0
 private void reCalc(PlanningModel planningModel)
 {
     AllItemsInTheTable.Clear();
     if (!allChangesForSecurityStock.ContainsKey(planningModel.ID))
     {
         allChangesForSecurityStock.Add(planningModel.ID, planningModel.safetyStock);
     }
     else
     {
         allChangesForSecurityStock.Remove(planningModel.ID);
         allChangesForSecurityStock.Add(planningModel.ID, planningModel.safetyStock);
     }
     AllItemsInTheTable.ForEach(i =>
     {
         if (i.ID == planningModel.ID)
         {
             i.safetyStock = planningModel.safetyStock;
         }
     });
     if (allParts != null)
     {
         allParts.ForEach(i => reCalculateProduction(i, 100, 0, planningModel));
     }
 }
Beispiel #12
0
 public async Task SetPlanning(PlanningModel planningModel)
 {
     await http.PostAsJsonAsync("Article/Plan", planningModel);
 }
Beispiel #13
0
        public ActionResult Planning()
        {
            PlanningModel model = new PlanningModel();

            model.BossFio     = "Петров Пётр Петрович";
            model.ochnCourses = new List <LearningCourse>();

            model.ochnCourses.Add(new LearningCourse()
            {
                Id         = 1,
                Name       = "Холодные звонки",
                IsRemote   = false,
                Status     = Status.None,
                DateChange = null
            });

            model.ochnCourses.Add(new LearningCourse()
            {
                Id          = 2,
                Name        = "Transact-SQL",
                IsRemote    = false,
                Status      = Status.ZaplanirovanaAvtomatom,
                DateChange  = new DateTime(2017, 04, 13),
                ChosenGroup = new Group()
                {
                    Area      = "г. Тобольск, ул. Мира, 19",
                    DateStart = new DateTime(2017, 04, 10),
                    DateEnd   = new DateTime(2017, 04, 12),
                    GroupName = "17-67-2099",
                    Lecturer  = "Галошкин П.Е."
                }
            });

            model.ochnCourses.Add(new LearningCourse()
            {
                Id          = 2,
                Name        = "1C Предприятие",
                IsRemote    = false,
                Status      = Status.ZaplanirovanaAvtomatom,
                DateChange  = new DateTime(2017, 04, 13),
                ChosenGroup = new Group()
                {
                    Area      = "г. Тобольск, ул. Мира, 19",
                    DateStart = new DateTime(2017, 04, 24),
                    DateEnd   = new DateTime(2017, 04, 26),
                    GroupName = "17-67-2099",
                    Lecturer  = "Петренко И.В."
                }
            });

            model.ochnCourses.Add(new LearningCourse()
            {
                Id         = 3,
                Name       = "Владение EXCEL 2010",
                IsRemote   = false,
                Status     = Status.Otkazana,
                DateChange = new DateTime(2017, 03, 30)
            });

            model.ochnCourses.Add(new LearningCourse()
            {
                Id          = 3,
                Name        = "Развитие лидерских качеств",
                IsRemote    = false,
                Status      = Status.Soglasovana,
                ChosenGroup = new Group()
                {
                    Area      = "г. Тюмень, Моск-ий тракт, 421",
                    DateStart = new DateTime(2017, 04, 10),
                    DateEnd   = new DateTime(2017, 04, 12),
                    GroupName = "17-67-2099",
                    Lecturer  = "Иванов Е.С."
                },
                DateChange = new DateTime(2017, 04, 13)
            });

            model.distCourses.Add(new LearningCourse()
            {
                Id       = 4,
                Name     = "Обращение с подарками",
                IsRemote = true,
                Status   = Status.None
            });

            model.distCourses.Add(new LearningCourse()
            {
                Id       = 5,
                Name     = "Проблемы при работе с кредитами",
                IsRemote = true,
                Status   = Status.None
            });

            model.distCourses.Add(new LearningCourse()
            {
                Id       = 6,
                Name     = "Соло на клавиатуре",
                IsRemote = true,
                Status   = Status.None
            });

            model.ochnCourses = model.ochnCourses.OrderBy(o => o.Status).ToList();

            return(View(model));
        }
Beispiel #14
0
 public async Task SetPlanning(PlanningModel planningModel)
 {
     await articleService.SetPlanning(planningModel);
 }