Beispiel #1
0
 public static bool ToCellonOptionDTO(CellonOption input, CellonOptionDTO output)
 {
     if (input == null)
     {
         return(false);
     }
     output.CellonOptionId    = input.CellonOptionId;
     output.EquipmentSerialId = input.EquipmentSerialId;
     output.Level             = input.Level;
     output.Type  = input.Type;
     output.Value = input.Value;
     return(true);
 }
Beispiel #2
0
 public IEnumerable <CellonOptionDTO> GetOptionsByWearableInstanceId(Guid wearableInstanceId)
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <CellonOptionDTO> result = new List <CellonOptionDTO>();
         foreach (CellonOption entity in context.CellonOption.Where(c => c.EquipmentSerialId == wearableInstanceId))
         {
             CellonOptionDTO dto = new CellonOptionDTO();
             Mapper.Mappers.CellonOptionMapper.ToCellonOptionDTO(entity, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
Beispiel #3
0
        private static CellonOptionDTO insert(CellonOptionDTO cellonOption, OpenNosContext context)
        {
            CellonOption entity = new CellonOption();

            Mapper.Mappers.CellonOptionMapper.ToCellonOption(cellonOption, entity);
            context.CellonOption.Add(entity);
            context.SaveChanges();
            if (Mapper.Mappers.CellonOptionMapper.ToCellonOptionDTO(entity, cellonOption))
            {
                return(cellonOption);
            }

            return(null);
        }
Beispiel #4
0
        private static CellonOptionDTO update(CellonOption entity, CellonOptionDTO cellonOption, OpenNosContext context)
        {
            if (entity != null)
            {
                Mapper.Mappers.CellonOptionMapper.ToCellonOption(cellonOption, entity);
                context.SaveChanges();
            }

            if (Mapper.Mappers.CellonOptionMapper.ToCellonOptionDTO(entity, cellonOption))
            {
                return(cellonOption);
            }

            return(null);
        }
Beispiel #5
0
        public CellonOptionDTO InsertOrUpdate(CellonOptionDTO cellonOption)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    long         cellonOptionId = cellonOption.CellonOptionId;
                    CellonOption entity         = context.CellonOption.FirstOrDefault(c => c.CellonOptionId.Equals(cellonOptionId));

                    if (entity == null)
                    {
                        return(insert(cellonOption, context));
                    }
                    return(update(entity, cellonOption, context));
                }
            }
            catch (Exception e)
            {
                Logger.Error(string.Format(Language.Instance.GetMessageFromKey("INSERT_ERROR"), cellonOption, e.Message), e);
                return(cellonOption);
            }
        }