Exemple #1
0
 private void InitDepartmentStateNode(DepartmentState departmentState, bool hasChildren)
 {
     Id           = departmentState.Id;
     Name         = departmentState.Department;
     Type         = "DepartmentState";
     _hasChildren = hasChildren;
 }
        protected Department(Int32 id, Uuid uuid, String name, DepartmentType type, DepartmentState state, Int32 timeZoneUTCOffset, Country country)
        {
            Id      = id;
            Uuid    = uuid;
            Name    = name;
            Type    = type;
            State   = state;
            Country = country;

            TimeZoneUTCOffset = timeZoneUTCOffset;
        }
        protected Department(Int32 id, Uuid uuid, String name, DepartmentType type, DepartmentState state,
                             Int32 timeZoneUTCOffset, Country country, String ownerName, String ownerPhone, String ownerEMail)
        {
            Id         = id;
            Uuid       = uuid;
            Name       = name;
            Type       = type;
            State      = state;
            Country    = country;
            OwnerName  = ownerName;
            OwnerPhone = ownerPhone;
            OwnerEMail = ownerEMail;

            TimeZoneUTCOffset = timeZoneUTCOffset;
        }
Exemple #4
0
        public PassEntitiesActionObject PassEntities(IEnumerable <string> userRoles, string userName, EntityOrganiserViewModel model)
        {
            DepartmentState          sourceDepartmentState = _unitOfWork.DepartmentStateRepository.GetDepartmentStateById(model.DepartmentStateId);
            DepartmentState          targetDepartmentState = _unitOfWork.DepartmentStateRepository.GetDepartmentStateByOrderIdAndLocNum(sourceDepartmentState.OrderId, sourceDepartmentState.LocationPosition + 1);
            PassEntitiesActionObject _actionObject         = new PassEntitiesActionObject();

            if (!userRoles.Any(x => x == targetDepartmentState.Name))
            {
                _actionObject.Success         = false;
                _actionObject.Message         = "Something went wrong, logout and log back in to fix the issue.";
                _actionObject.RedirectToError = true;
            }

            if (sourceDepartmentState.EntitiesRFC >= model.EntitiesPassed)
            {
                sourceDepartmentState.EntitiesRFC -= model.EntitiesPassed;
            }
            else
            {
                _actionObject.Success         = false;
                _actionObject.Message         = "Entity count insufficient.";
                _actionObject.RedirectToError = true;
            }

            if (targetDepartmentState.Status == ((Enums.Statuses) 1).ToString())
            {
                targetDepartmentState.Status = ((Enums.Statuses) 2).ToString();
                targetDepartmentState.Start  = DateTime.Now;
            }

            targetDepartmentState.EntitiesInProgress += model.EntitiesPassed;

            _unitOfWork.Update(sourceDepartmentState);
            _unitOfWork.Update(targetDepartmentState);

            _unitOfWork.Complete();
            _unitOfWork.LogRepository.CreateLog(
                userName,
                "Moved " + model.EntitiesPassed.ToString() + " " + _unitOfWork.OrderRepository.Find(x => x.OrderId == sourceDepartmentState.OrderId).FirstOrDefault().EntityType + " from " + sourceDepartmentState.Name + " to " + targetDepartmentState.Name + ".",
                DateTime.Now,
                _unitOfWork.OrderRepository.Find(o => o.OrderId == sourceDepartmentState.OrderId)
                .Select(o => o.OrderNumber).FirstOrDefault());

            _actionObject.Source = sourceDepartmentState;
            _actionObject.Target = targetDepartmentState;

            return(_actionObject);
        }
Exemple #5
0
        private string GetDepartmentName()
        {
            var result = "";

            if (_id.HasValue)
            {
                _department = DBHelper.GetDepartmentState(_id.Value);
                if (_department == null)
                {
                    _division = DBHelper.GetDivisionState(_id.Value);
                    if (_division != null)
                    {
                        result = _division.Division;
                    }
                }
                else
                {
                    result = _department.Department;
                }
            }


            return(result);
        }
Exemple #6
0
 public TreeViewNode(DepartmentState departmentState, bool hasChildren) : this()
 {
     InitDepartmentStateNode(departmentState, hasChildren);
 }
        public MarkAsReadyActionObject MarkAsReady(EntityOrganiserViewModel model, string currentUserName)
        {
            using (_unitOfWork)
            {
                Dictionary <string, string> result = new Dictionary <string, string>();

                MarkAsReadyActionObject _actionResult    = new MarkAsReadyActionObject();
                DepartmentState         _departmentState = new DepartmentState();
                _departmentState = _unitOfWork.DepartmentStateRepository.GetDepartmentStateById(model.DepartmentStateId);

                var    order             = _unitOfWork.OrderRepository.GetById(_departmentState.OrderId);
                string additionalMessage = "";

                if (_departmentState.EntitiesInProgress < model.EntitiesPassed)
                {
                    _actionResult.Result.Add("MessageType", "Error");
                    _actionResult.Result.Add("Message", "There are only " + _departmentState.EntitiesInProgress.ToString() + " entities in progress. Refresh the page.");
                    return(_actionResult);
                }

                _departmentState.EntitiesRFC        += model.EntitiesPassed;
                _departmentState.EntitiesInProgress -= model.EntitiesPassed;
                _departmentState.EntitiesPassed     += model.EntitiesPassed;

                if (_departmentState.TotalEntityCount == _departmentState.EntitiesPassed)
                {
                    _departmentState.Status = ((Enums.Statuses) 3).ToString();
                    _departmentState.Finish = DateTime.Now;
                }

                //TODO test this if statement

                if (_unitOfWork.DepartmentStateRepository.IsLastOrderDepartmentState(_departmentState.OrderId, _departmentState.DepartmentStateId))
                {
                    order.EntitiesCompleted += model.EntitiesPassed;
                    if (_departmentState.EntitiesRFC == order.EntityCount)
                    {
                        order.FinshedAt   = DateTime.Now;
                        order.Status      = ((Enums.Statuses) 3).ToString();
                        additionalMessage = "Order status: " + ((Enums.Statuses) 3).ToString() + ".";
                    }
                    _unitOfWork.Update(order);
                }
                _unitOfWork.Update(_departmentState);
                _unitOfWork.Complete();

                result.Add("MessageType", "Success");

                result.Add("Message", model.EntitiesPassed.ToString() +
                           " entities successfully marked as ready for collection!" + additionalMessage);

                _unitOfWork.LogRepository.CreateLog(
                    currentUserName,
                    "Marked " + model.EntitiesPassed.ToString() + " " + order.EntityType + " as ready for collection.",
                    DateTime.Now,
                    order.OrderNumber);

                _actionResult.Result          = result;
                _actionResult.DepartmentState = _departmentState;
                return(_actionResult);
            }
        }