EnVisageOnline/Main/Source/EnVisage/Models/MongoDBBackupModel.cs

59 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using EnVisage.Code;
namespace EnVisage.Models
{
class MongoDBBackupModel : IBaseModel<supt_tbl_MongoDBBackup>
{
public System.Guid Id { get; set; }
public System.DateTime BackupDate { get; set; }
public string BackupedBy { get; set; }
public string BackupData { get; set; }
public string CollectionName { get; set; }
/// <summary>
/// Casts a <see cref="supt_tbl_MongoDBBackup"/> obect to the object of type <see cref="supt_tbl_MongoDBBackup"/>.
/// </summary>
/// <param name="obj">A <see cref="supt_tbl_MongoDBBackup"/> object.</param>
/// <returns>A <see cref="MongoDBBackupModel"/> object filled with data from db.</returns>
public static explicit operator MongoDBBackupModel(supt_tbl_MongoDBBackup obj)
{
if (obj == null)
return null;
var model = new MongoDBBackupModel
{
Id = obj.id,
BackupData=obj.BackupData,
BackupDate=obj.BackupDate,
BackupedBy=obj.BackupedBy,
CollectionName=obj.CollectionName
};
model.TrimStringProperties();
return model;
}
/// <summary>
/// Copies data from model to DAL object.
/// </summary>
/// <param name="dbObj">A target DAL object.</param>
public void CopyTo(supt_tbl_MongoDBBackup dbObj)
{
if (dbObj == null)
throw new ArgumentNullException();
dbObj.CollectionName = CollectionName;
dbObj.BackupData = BackupData;
dbObj.BackupDate = BackupDate;
dbObj.BackupedBy = BackupedBy;
}
}
}