public static void ApplyUpdate(this Database.AssetThreat_Attributes dataItem, Contracts.Attribute.Attribute update) { dataItem.Name = update.Name; dataItem.Description = update.Description; dataItem.UpdatedOn = DateTime.Now; dataItem.Comment = update.Comment; dataItem.AttributeCategoryId = update.AttributeCategoryId; dataItem.MonthTimeframe = (int?)update.Timeframe.Months; dataItem.DayTimeframe = (int?)update.Timeframe.Days; dataItem.HourTimeframe = (int?)update.Timeframe.Hours; dataItem.Source = update.Source; }
public static Contracts.Attribute.Attribute ToContract(this Database.AssetThreat_Attributes dataItem, bool isFirstLevel = true) { return(new Contracts.Attribute.Attribute { AttributeCategoryId = dataItem.AttributeCategoryId, AttributeCategoryName = dataItem.AttributeCategory != null ? dataItem.AttributeCategory.Name : "", Name = dataItem.Name, Description = dataItem.Description, CreatedOn = dataItem.CreatedOn, UpdatedOn = dataItem.UpdatedOn, AttributeTypeId = dataItem.AttributeTypeId, AttributeId = dataItem.AttributeId, Comment = dataItem.Comment, Source = dataItem.Source, ChildAttributes = isFirstLevel ? dataItem.Attribute.AttributeLinks1.Select(al => al.Attribute.ToContract(false)).ToList() : new List <Attribute>(), Timeframe = new Timeframe { Months = dataItem.MonthTimeframe != null ? (MonthTimeframe)dataItem.MonthTimeframe : MonthTimeframe.None, Days = dataItem.DayTimeframe != null ? (DayTimeframe)dataItem.DayTimeframe : DayTimeframe.None, Hours = dataItem.HourTimeframe != null ? (HourTimeframe)dataItem.HourTimeframe : HourTimeframe.None } }); }