/// <summary> /// Converts this instance of <see cref="recommendation"/> to an instance of <see cref="recommendationDto"/>. /// </summary> /// <param name="entity"><see cref="recommendation"/> to convert.</param> public static recommendationDto ToDTO(this recommendation entity) { if (entity == null) { return(null); } var dto = new recommendationDto(); dto.v_RecommendationId = entity.v_RecommendationId; dto.v_ServiceId = entity.v_ServiceId; dto.v_DiagnosticRepositoryId = entity.v_DiagnosticRepositoryId; dto.v_ComponentId = entity.v_ComponentId; dto.v_MasterRecommendationId = entity.v_MasterRecommendationId; dto.i_IsDeleted = entity.i_IsDeleted; dto.i_InsertUserId = entity.i_InsertUserId; dto.d_InsertDate = entity.d_InsertDate; dto.i_UpdateUserId = entity.i_UpdateUserId; dto.d_UpdateDate = entity.d_UpdateDate; dto.v_ComentaryUpdate = entity.v_ComentaryUpdate; entity.OnDTO(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="recommendationDto"/> to an instance of <see cref="recommendation"/>. /// </summary> /// <param name="dto"><see cref="recommendationDto"/> to convert.</param> public static recommendation ToEntity(this recommendationDto dto) { if (dto == null) { return(null); } var entity = new recommendation(); entity.v_RecommendationId = dto.v_RecommendationId; entity.v_ServiceId = dto.v_ServiceId; entity.v_DiagnosticRepositoryId = dto.v_DiagnosticRepositoryId; entity.v_ComponentId = dto.v_ComponentId; entity.v_MasterRecommendationId = dto.v_MasterRecommendationId; entity.i_IsDeleted = dto.i_IsDeleted; entity.i_InsertUserId = dto.i_InsertUserId; entity.d_InsertDate = dto.d_InsertDate; entity.i_UpdateUserId = dto.i_UpdateUserId; entity.d_UpdateDate = dto.d_UpdateDate; entity.v_ComentaryUpdate = dto.v_ComentaryUpdate; dto.OnEntity(entity); return(entity); }
public bool SaveTopData(Dictionary <int, TopDataModel> dict, DateTime dateTime) { using (userEntities userEntities = new userEntities()) { using (var tran = userEntities.Database.BeginTransaction()) { try { var dataList = userEntities.recommendation.Where(p => p.data_date == dateTime).ToList(); if (dataList.Count > 0) { userEntities.recommendation.RemoveRange(dataList); userEntities.SaveChanges(); } foreach (var item in dict) { recommendation data = new recommendation(); data.create_id = 1; data.create_name = "admin"; data.create_time = HelpFunction.ConvertToTimestamp(DateTime.Now); data.data_date = item.Value.Date; data.icon = item.Value.ImgaeUrl; data.order_index = item.Value.OrderIndex; data.source_id = item.Value.SourceId; data.source_type = item.Value.SourceTypeInt; data.source_title = item.Value.Title; userEntities.recommendation.Add(data); } userEntities.SaveChanges(); tran.Commit(); return(true); } catch (Exception ex) { tran.Rollback(); Trace.WriteLine(ex); } } } return(false); }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="recommendation"/> converted from <see cref="recommendationDto"/>.</param> static partial void OnEntity(this recommendationDto dto, recommendation entity);
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="recommendationDto"/> converted from <see cref="recommendation"/>.</param> static partial void OnDTO(this recommendation entity, recommendationDto dto);