示例#1
0
 public unit GetUnitByID(Guid id)
 {
     using (var context = new Entities())
     {
         unit item = context.unit.SingleOrDefault(u => u.systemId == id.ToString());
         if (item != null)
             return item;
     }
     return null;
 }
示例#2
0
        public void InsertUnitRecord(UnitRecord record, unit ownerUnit)
        {
            using (var context = new Entities())
            {
                unit_record newRecord = new unit_record()
                {
                    unit = ownerUnit,
                    currentTime = record.CurrnetTime,
                    weight = record.Weight,
                    speed = record.Speed
                };
                context.unit_record.Add(newRecord);
                context.SaveChanges();

            }
        }
示例#3
0
        public unit InsertUnit(Guid systemId)
        {
            using (var context = new Entities())
            {
                unit existUnit = GetUnitByID(systemId);
                if (existUnit != null)
                    return existUnit;

                unit newUnit = new unit()
                {
                    systemId = systemId.ToString(),
                    created = DateTime.Now
                };

                context.unit.Add(newUnit);
                context.SaveChanges();

                return newUnit;
            }
        }