Exemplo n.º 1
0
 public static ScrimActionTypeDomain GetDomainFromActionType(ScrimActionType action)
 {
     if ((int)action >= 10 && (int)action < 100)
     {
         return(ScrimActionTypeDomain.Objective);
     }
     else if ((int)action >= 300 && (int)action < 399)
     {
         return(ScrimActionTypeDomain.Support);
     }
     else if ((int)action >= 100 && (int)action < 200)
     {
         return(ScrimActionTypeDomain.Infantry);
     }
     else if ((int)action >= 200 && (int)action < 300)
     {
         return(ScrimActionTypeDomain.MAX);
     }
     else if ((int)action >= 400 && (int)action < 500)
     {
         return(ScrimActionTypeDomain.Vehicle);
     }
     else if ((int)action >= 500 && (int)action < 1999)
     {
         return(ScrimActionTypeDomain.AirVehicle);
     }
     else if ((int)action >= 2000 && (int)action < 2999)
     {
         return(ScrimActionTypeDomain.GroundVehicle);
     }
     else
     {
         return(ScrimActionTypeDomain.Other);
     }
 }
        private ScrimActionType Save(ScrimActionTypeDto dto)
        {
            ScrimActionType entity = null;

            try
            {
                if (dto.ID == 0)
                {
                    entity = new ScrimActionType();
                    Mapper.Map(dto, entity);
                    _repository.Repository <ScrimActionType>().Insert(entity);
                }
                else
                {
                    entity = GetById(dto.ID);
                    Mapper.Map(dto, entity);
                    _repository.Repository <ScrimActionType>().Update(entity);
                }
                _repository.Save();
            }
            catch (DbEntityValidationException valEx)
            {
                HandleValidationException(valEx);
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }
            return(entity);
        }
Exemplo n.º 3
0
 private RulesetActionRule BuildRulesetActionRule(ScrimActionType actionType, int points = 0, bool deferToItemCategoryRules = false)
 {
     return(new RulesetActionRule
     {
         ScrimActionType = actionType,
         Points = points,
         DeferToItemCategoryRules = deferToItemCategoryRules
     });
 }
 private RulesetActionRule BuildRulesetActionRule(ScrimActionType actionType, int points = 0, bool deferToItemCategoryRules = false)
 {
     return(new RulesetActionRule
     {
         ScrimActionType = actionType,
         Points = points,
         DeferToItemCategoryRules = deferToItemCategoryRules,
         ScrimActionTypeDomain = ScrimAction.GetDomainFromActionType(actionType)
     });
 }
Exemplo n.º 5
0
        private ScrimAction ConvertToDbModel(ScrimActionType value)
        {
            var name = Enum.GetName(typeof(ScrimActionType), value);

            return(new ScrimAction
            {
                Action = value,
                Name = name,
                Description = Regex.Replace(name, @"(\p{Ll})(\p{Lu})", "$1 $2")
            });
        }
        public int Add(ScrimActionTypeDto dto)
        {
            ScrimActionType entity = Save(dto);

            if (entity != null)
            {
                return(entity.ID);
            }
            else
            {
                return(-1);
            }
        }
Exemplo n.º 7
0
        private void UpdateScrimUsageEntryForContractorRoll(TPOCProductRollDto tpoCProductRollDto, double divisor)
        {
            DateTime        now   = DateTime.Now;
            TPOBatch        batch = _repository.Repository <TPOBatch>().GetAllBy(b => b.BatchNumber == tpoCProductRollDto.BatchNumber && b.IsScrim == true).FirstOrDefault();
            ScrimRoll       roll  = _repository.Repository <ScrimRoll>().GetById(batch.ScrimRollID);
            ScrimActionType type  = _repository.Repository <ScrimActionType>().GetAllBy(t => t.Code == "PR" && t.PlantID == tpoCProductRollDto.PlantID).FirstOrDefault();

            double actionLength = (double)ConvertUoM(tpoCProductRollDto.Length, tpoCProductRollDto.LengthUoMID, roll.LengthUoMID) / divisor;
            double actionWeight = (double)ConvertUoM(tpoCProductRollDto.Weight, tpoCProductRollDto.WeightUoMID, roll.WeightUoMID) / divisor;

            ScrimAction action = new ScrimAction()
            {
                ActionDate       = now,
                ActionLength     = actionLength,
                ActionReasonText = "Production Entry",
                ActionWeight     = actionWeight,
                DateEntered      = now,
                EndLength        = roll.Length - actionLength,
                EndWeight        = roll.Weight - actionWeight,
                EnteredBy        = tpoCProductRollDto.ModifiedBy,
                FleeceProd       = false,
                LastModified     = now,
                LineID           = tpoCProductRollDto.LineID,
                ModifiedBy       = tpoCProductRollDto.ModifiedBy,
                PlantID          = tpoCProductRollDto.PlantID,
                ReasonID         = null,
                RollID           = null,
                ScrimRollID      = roll.ID,
                ShiftID          = tpoCProductRollDto.ShiftID,
                StartLength      = roll.Length,
                StartWeight      = roll.Weight,
                TypeID           = type.ID
            };

            _repository.Repository <ScrimAction>().Insert(action);
        }
Exemplo n.º 8
0
 public string GetEnumValueName(ScrimActionType action)
 {
     return(Enum.GetName(typeof(ScrimActionType), action));
 }
 private ScrimActionTypeDto MapEntity(ScrimActionType entity)
 {
     return(Mapper.Map <ScrimActionType, ScrimActionTypeDto>(entity));
 }