public int SaveUserInstanceUsage(IUserInstanceUsageDb userInstanceUsageDb, int? transactionNumber = null)
        {
            UserInstanceUsage record;
            var recordOld = new UserInstanceUsage();
            if (userInstanceUsageDb.UserInstanceUsageId == 0)
            {
                record = new UserInstanceUsage();
                Context.AddToUserInstanceUsages(record);
            }
            else
            {
                record = Context.UserInstanceUsages.Where(r => r.UserInstanceUsageId == userInstanceUsageDb.UserInstanceUsageId).First();
                ReflectionHelper.CopyAllProperties(record, recordOld);
            }

            record.UserId = userInstanceUsageDb.UserId;
            record.UsedInstanceId = userInstanceUsageDb.UsedInstanceId;
            record.Date = userInstanceUsageDb.Date;

            Context.SaveChanges();
            if (userInstanceUsageDb.UserInstanceUsageId == 0)
            {
                userInstanceUsageDb.UserInstanceUsageId = record.UserInstanceUsageId;
                LogUnlinkedToDb(UserId, "UserInstanceUsages", record.UserInstanceUsageId, "I", XmlHelper.GetObjectXml(record), transactionNumber);
            }
            else
            {
                LogUnlinkedToDb(UserId, "UserInstanceUsages", record.UserInstanceUsageId, "U", XmlHelper.GetDifferenceXml(recordOld, record), transactionNumber);
            }

            return userInstanceUsageDb.UserInstanceUsageId;
        }
 public void AddToUserInstanceUsages(UserInstanceUsage record)
 {
     _context.AddToUserInstanceUsages(record);
 }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserInstanceUsages EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserInstanceUsages(UserInstanceUsage userInstanceUsage)
 {
     base.AddObject("UserInstanceUsages", userInstanceUsage);
 }
Пример #4
0
 /// <summary>
 /// Create a new UserInstanceUsage object.
 /// </summary>
 /// <param name="userInstanceUsageId">Initial value of the UserInstanceUsageId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="usedInstanceId">Initial value of the UsedInstanceId property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static UserInstanceUsage CreateUserInstanceUsage(global::System.Int32 userInstanceUsageId, global::System.Int32 userId, global::System.Int32 usedInstanceId, global::System.DateTime date)
 {
     UserInstanceUsage userInstanceUsage = new UserInstanceUsage();
     userInstanceUsage.UserInstanceUsageId = userInstanceUsageId;
     userInstanceUsage.UserId = userId;
     userInstanceUsage.UsedInstanceId = usedInstanceId;
     userInstanceUsage.Date = date;
     return userInstanceUsage;
 }