Esempio n. 1
0
        public bool Add(BuildingQueueDto buildingQueue)
        {
            try
            {
                DateTime tempDate;
                if (buildingQueue.NewStatus.ToLower().Contains("budowa") || buildingQueue.NewStatus.ToLower().Contains("rozbudowa"))
                {
                    tempDate = DateTime.Now.AddSeconds(_usersBuilding.Get(buildingQueue.UserBuilding_ID).Buildings.BuildingTime);
                }
                else if (buildingQueue.NewStatus.ToLower().Contains("burzenie"))
                {
                    tempDate = DateTime.Now.AddSeconds(_usersBuilding.Get(buildingQueue.UserBuilding_ID).Buildings.DestructionTime);
                }
                else
                {
                    tempDate = DateTime.Now;
                }

                _buildingQueue.Add(new BuildingQueue
                {
                    User_ID = _user.GetAll().First(i => i.Login == buildingQueue.Login).ID,
                    UserBuilding_ID = buildingQueue.UserBuilding_ID,
                    FinishTime = /*(DateTime)tempDate*/ DateTime.Now,
                    NewStatus = buildingQueue.NewStatus
                });

                _unitOfWork.Commit();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Esempio n. 2
0
        public ActionResult AddQueue(QueueViewModel queueModel)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            BuildingQueueDto _queueDto = new BuildingQueueDto();

            _queueDto.Login = queueModel.viewModel.User_Login;
            _queueDto.UserBuilding_ID = queueModel.viewModel.UserBuilding_ID;
            _queueDto.NewStatus = queueModel.viewModel.NewStatus;

            if(_queueService.Add(_queueDto))
            {
                errors.Add("Dodano budynek do kolejki.");
            }
            else
            {
                errors.Add("Błąd. Spróbuj ponownie.");
            }
            Session["val"] = errors.ToArray<string>();

            return RedirectToAction("Admin");
        }
Esempio n. 3
0
        public bool Update(BuildingQueueDto buildingQueue)
        {
            try
            {
                foreach (var item in _buildingQueue.GetAll().Where(i => i.ID == buildingQueue.ID))
                {
                    item.User_ID = _user.GetAll().First(i => i.Login == buildingQueue.Login).ID;
                    item.UserBuilding_ID = buildingQueue.UserBuilding_ID;
                    item.FinishTime = buildingQueue.FinishTime;
                    item.NewStatus = buildingQueue.NewStatus;
                }

                _unitOfWork.Commit();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Esempio n. 4
0
        public ActionResult UpdateQueue(QueueViewModel queueModel)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            BuildingQueueDto _buildingQueueDto = new BuildingQueueDto();

            _buildingQueueDto.ID = queueModel.viewModel.ID;
            _buildingQueueDto.Login = queueModel.viewModel.User_Login;
            _buildingQueueDto.UserBuilding_ID = queueModel.viewModel.UserBuilding_ID;
            _buildingQueueDto.NewStatus = queueModel.viewModel.NewStatus;
            _buildingQueueDto.FinishTime = queueModel.viewModel.FinishDate;

            if(_queueService.Update(_buildingQueueDto))
            {
                errors.Add("Zaktualizowano budynek w kolejce.");
            }
            else
            {
                errors.Add("Błąd. Spróbuj ponownie.");
            }
            Session["val"] = errors.ToArray<string>();

            return RedirectToAction("Admin");
        }