本文整理汇总了C#中Eme.Model.Eme.EmeEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# EmeEntities.SaveChanges方法的具体用法?C# EmeEntities.SaveChanges怎么用?C# EmeEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eme.Model.Eme.EmeEntities
的用法示例。
在下文中一共展示了EmeEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMessage
/// <summary>
/// 作者:Vincen
/// 时间:2014.04.30
/// 描述:创建消息
/// </summary>
/// <param name="model"></param>
/// <param name="loginUserId"></param>
/// <returns></returns>
public static bool CreateMessage(MessageModel model, int loginUserId)
{
try
{
using (var tran = new TransactionScope())
{
using (var edb = new EmeEntities())
{
var msg = new Message()
{
MessageType = model.MessageType,
Subject = model.Subject,
MContent = model.MContent,
Receivers = model.Receiver.Count,
Openers = 0,
Status = ConvertEnum.StatusTypeForActive,
CreateBy = model.CreateBy,
CreateTime = model.CreateTime
};
edb.Entry(msg).State = EntityState.Added;
edb.SaveChanges();
var receiver = from a in model.Receiver
select new MessageReceiver()
{
MessageId = msg.Id,
Receiver = a,
IsRead = false,
Status = ConvertEnum.StatusTypeForActive,
CreateBy = model.CreateBy,
CreateTime = model.CreateTime
};
foreach (var messageReceiver in receiver)
{
edb.Entry(messageReceiver).State = EntityState.Added;
}
var result = edb.SaveChanges() > 0;
tran.Complete();
return result;
}
}
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("EmeBLL-CreateMessage:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = loginUserId,
CreateTime = DateTime.Now
});
return false;
}
}
示例2: AddProductBranch
/// <summary>
/// 作者:Raymond
/// 日期:2014-4-22
/// 描述:新增中心产品
/// </summary>
/// <param name="pBranch"></param>
/// <param name="loginUserId"></param>
/// <returns></returns>
public static bool AddProductBranch(ProductBranch pBranch, int loginUserId)
{
using (var edb = new EmeEntities())
{
try
{
edb.Entry(pBranch).State = EntityState.Added;
var result = edb.SaveChanges() > 0;
return result;
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("ProductBLL-AddProductBranch:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = loginUserId,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例3: CreateCourse
/// <summary>
/// 作者:Vincen
/// 时间:2014.04.01
/// 描述:创建课程
/// </summary>
/// <param name="course"></param>
/// <param name="loginUserId"></param>
/// <returns></returns>
public static Course CreateCourse(Course course, int loginUserId)
{
using (var edb = new EmeEntities())
{
try
{
edb.Entry(course).State = EntityState.Added;
edb.SaveChanges();
return course;
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("CourseBLL-CreateCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = loginUserId,
CreateTime = DateTime.Now
});
return null;
}
}
}
示例4: CheckContractDetail
/// <summary>
/// 作者:Vincen
/// 时间:2014.07.18
/// 描述:检查合同详情
/// </summary>
/// <returns></returns>
public static bool CheckContractDetail()
{
using (var edb = new EmeEntities())
{
try
{
foreach (var detail in
edb.ContractDetail.Where(
p => p.Status == ConvertEnum.StatusTypeForActive && p.EndDate < DateTime.Now && p.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute))
{
// 更新结束的合同为结束状态
detail.ContractStatusType = ConvertEnum.ContractStatusTypeForOver;
edb.Entry(detail).State = EntityState.Modified;
}
var result = edb.SaveChanges() > 0;
return result;
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("StudentBLL-CheckContractDetail:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = null,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例5: CreateClassroom
/// <summary>
/// 作者:Vincen
/// 时间:2014.03.28
/// 描述:创建教室
/// </summary>
/// <param name="model"></param>
/// <param name="createBy"></param>
/// <returns></returns>
public static bool CreateClassroom(Classroom model, int createBy)
{
using (var edb = new EmeEntities())
{
try
{
edb.Entry(model).State = EntityState.Added;
var result = edb.SaveChanges() > 0;
return result;
}
catch (Exception e)
{
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Message),
Message = string.Format("BranchBLL-CreateClassroom:{0};{1};{2}", e.Message, e.InnerException, e.HelpLink),
IsTreat = false,
UserHostAddress = WebHelper.GetCurrentIpAddress(),
CreateBy = createBy,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例6: CreateReferral
/// <summary>
/// 作者:Raymond
/// 日期:2014-6-27
/// 描述:新增报备
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static bool CreateReferral(Referral model)
{
using (var edb = new EmeEntities())
{
edb.Entry(model).State = EntityState.Added;
return edb.SaveChanges() > 0;
}
}
示例7: CreateFollow
/// <summary>
/// 作者:Kylin
/// 时间:2014.03.21 PM
/// 描述:(学员)Follow Up (批量)发送
/// </summary>
/// <param name="model"></param>
/// <param name="followDetailLst"></param>
/// <param name="followAttachmentLst"></param>
/// <returns></returns>
public static bool CreateFollow(Follow model, List<FollowDetail> followDetailLst, List<FollowAttachment> followAttachmentLst)
{
using (var edb = new EmeEntities())
{
try
{
edb.Entry<Follow>(model).State = EntityState.Added;
foreach (var item in followDetailLst)
{
item.FollowId = model.Id;
edb.Entry<FollowDetail>(item).State = EntityState.Added;
var student = edb.Student.SingleOrDefault(p => p.Id == item.StudentId);
if (student != null)
{
var studentUserId = student.UserId;
// 发送队列消息
//EmeBLL.CreateMessageForSFollowUp(studentUserId, model.CreateBy);
var msg = new MessageModel()
{
MessageType = CommonHelper.To<int>(MessageType.System),
Subject = "Follow Up 查看提醒",
MContent = string.Format("您有SA新发送的FU,请注意查收;"),
Receiver = new List<int>(),
CreateBy = model.CreateBy,
CreateTime = DateTime.Now
};
msg.Receiver.Add(studentUserId);
// 将消息加入队列
Common.MSMQ.QueueManager.AddSystemMessage(msg);
}
}
foreach (var attachment in followAttachmentLst)
{
attachment.FollowId = model.Id;
edb.Entry(attachment).State = EntityState.Added;
}
var result = edb.SaveChanges() > 0;
return result;
}
catch (Exception ex)
{
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Message),
Message = string.Format("FollowBLL-CreateFollow:{0};{1};{2}", ex.Message, ex.InnerException, ex.HelpLink),
IsTreat = false,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例8: CreateCourseware
/// <summary>
/// 作者:Primo
/// 时间:2014.07.02
/// 描述:创建课程附件
/// </summary>
/// <param name="courseware"></param>
/// <param name="coursewareDetail"></param>
/// <returns></returns>
public static bool CreateCourseware(Courseware courseware, CoursewareDetail coursewareDetail)
{
using (var tran = new TransactionScope())
{
using (var edb = new EmeEntities())
{
try
{
edb.Entry(courseware).State = EntityState.Added;
edb.SaveChanges();
coursewareDetail.CoursewareId = courseware.Id;
edb.Entry(coursewareDetail).State = EntityState.Added;
var result = edb.SaveChanges() > 0;
tran.Complete();
return result;
}
catch (Exception e)
{
tran.Dispose();
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("CourseBLL-CreateCourseware:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = courseware.CreateBy,
CreateTime = DateTime.Now
});
return false;
}
}
}
}
示例9: UpdateProductLevelConfig
/// <summary>
/// 作者:Kylin
/// 时间:2014.03.27
/// 描述:更新产品级别配置
/// </summary>
/// <param name="model"></param>
/// <param name="loginUserId"></param>
/// <returns></returns>
public static bool UpdateProductLevelConfig(ProductLevelConfig model, int loginUserId)
{
using (var edb = new EmeEntities())
{
try
{
var modelObj = edb.ProductLevelConfig.FirstOrDefault(a => a.Id == model.Id && a.Status == ConvertEnum.StatusTypeForActive);
if (null == modelObj)
return false;
modelObj.Status = model.Status;
modelObj.UpdateBy = model.UpdateBy;
modelObj.UpdateTime = model.UpdateTime;
modelObj.ProductLevelId = model.ProductLevelId;
modelObj.IsOptional = model.IsOptional;
modelObj.Optional = model.Optional;
edb.Entry(modelObj).State = EntityState.Modified;
var result = edb.SaveChanges() > 0;
return result;
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("ProductBLL-UpdateProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = loginUserId,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例10: UpdateProductLevel
/// <summary>
/// 作者:Raymond
/// 日期:2014-3-5
/// 描述:更新产品级别,不含产品必修、选修信息
/// </summary>
/// <param name="pLevel"></param>
/// <param name="loginUserId"></param>
/// <returns></returns>
public static bool UpdateProductLevel(ProductLevel pLevel, int loginUserId)
{
using (var edb = new EmeEntities())
{
try
{
var pLevelObj = edb.ProductLevel.FirstOrDefault(p => p.Id == pLevel.Id);
if (null == pLevelObj)
return false;
pLevelObj.CName = pLevel.CName;
pLevelObj.EName = pLevel.EName;
pLevelObj.SCode = pLevel.SCode;
if (pLevel.OrderNum.HasValue)
pLevelObj.OrderNum = pLevel.OrderNum.Value;
pLevelObj.Description = pLevel.Description;
pLevelObj.Remark = pLevel.Remark;
pLevelObj.UpdateBy = pLevel.UpdateBy;
pLevelObj.UpdateTime = pLevel.UpdateTime;
edb.Entry(pLevelObj).State = EntityState.Modified;
var result = edb.SaveChanges() > 0;
return result;
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("ProductBLL-UpdateProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = loginUserId,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例11: AddProductLevel
/// <summary>
/// 作者:Raymond
/// 日期:2014-3-5
/// 描述:新增课程级别 、明细
/// </summary>
/// <param name="pLevel"></param>
/// <param name="requiredCourse"></param>
/// <param name="electiveCourse"></param>
/// <param name="createBy"></param>
/// <returns></returns>
public static bool AddProductLevel(ProductLevel pLevel, string requiredCourse, string electiveCourse, int createBy)
{
using (var edb = new EmeEntities())
{
try
{
edb.Entry(pLevel).State = EntityState.Added;
var flag = edb.SaveChanges() > 0;
if (flag)
{
var productLevelId = pLevel.Id;
//处理必修课
if (requiredCourse.Length > 0)
{
var rList = requiredCourse.Split('&');
foreach (var item in rList)
{
var rListDetail = item.Split('^');
var pCourseTypeId = CommonHelper.To<int>(rListDetail[1]);
var courses = CommonHelper.To<int>(rListDetail[2]);
var students = CommonHelper.To<int>(rListDetail[3]);
var pLevelCourseType = new ProductLevelCourseType()
{
ProductLevelId = productLevelId,
ProductCourseTypeId = pCourseTypeId,
SelectivityType = CommonHelper.To<int>(SelectivityType.Required),
Courses = courses,
Students = students,
Status = CommonHelper.To<int>(StatusType.Active),
CreateBy = createBy,
CreateTime = DateTime.Now
};
edb.Entry(pLevelCourseType).State = EntityState.Added;
}
}
//处理选修课
if (electiveCourse.Length > 0)
{
var eList = electiveCourse.Split('&');
if (eList.Any())
{
foreach (var item in eList)
{
var eListDetail = item.Split('^');
var pCourseTypeId = CommonHelper.To<int>(eListDetail[1]);
var courses = CommonHelper.To<int>(eListDetail[2]);
var students = CommonHelper.To<int>(eListDetail[3]);
var pLevelCourseType = new ProductLevelCourseType()
{
ProductLevelId = productLevelId,
ProductCourseTypeId = pCourseTypeId,
SelectivityType = CommonHelper.To<int>(SelectivityType.Elective),
Courses = courses,
Students = students,
Status = CommonHelper.To<int>(StatusType.Active),
CreateBy = createBy,
CreateTime = DateTime.Now
};
edb.Entry(pLevelCourseType).State = EntityState.Added;
}
}
}
}
return edb.SaveChanges() > 0;
}
catch
{
return false;
}
}
}
示例12: CreateProductLevelCourseTypeForProductLevel
/// <summary>
/// 作者:Primo
/// 日期:2014.06.24
/// 描述:新增夸产品课节
/// </summary>
/// <param name="productLevelCourseTypeId"></param>
/// <param name="list"></param>
/// <param name="loginUserId"></param>
/// <returns></returns>
public static bool CreateProductLevelCourseTypeForProductLevel(int productLevelCourseTypeId, List<ProductLevelCourseTypeForProductLevel> list, int loginUserId)
{
using (var edb = new EmeEntities())
{
try
{
var result = false;
var model = edb.ProductLevelCourseTypeForProductLevel.Where(p => p.ProductLevelCourseTypeId == productLevelCourseTypeId);
foreach (var item in model)
{
edb.Entry(item).State = EntityState.Deleted;
}
foreach (var item in list)
{
edb.Entry(item).State = EntityState.Added;
}
result = edb.SaveChanges() > 0;
return result;
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("ProductBLL-CreateProductLevelCourseTypeForProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = loginUserId,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例13: DeleteProductLevelCourseTypes
/// <summary>
/// 作者:Raymond
/// 日期:2014-2-14
/// 描述:删除课程级别对应的课程类型
/// </summary>
/// <param name="productLevelId"></param>
/// <param name="editIds"></param>
/// <param name="newIds"></param>
/// <returns></returns>
public bool DeleteProductLevelCourseTypes(int productLevelId, string editIds, string newIds)
{
using (var edb = new EmeEntities())
{
var productLevelCourseTypeList =
edb.ProductLevelCourseType.Where(p => p.ProductLevelId == productLevelId).ToList();
foreach (var item in productLevelCourseTypeList)
{
var IdKey = "," + item.ProductCourseTypeId.ToString() + ",";
if (editIds.IndexOf(IdKey) < 0 && newIds.IndexOf(IdKey) < 0)
{
item.Status = ConvertEnum.StatusTypeForDelete;
edb.Entry(item).State = EntityState.Modified;
}
}
return edb.SaveChanges() > 0;
}
}
示例14: CancelProductCourseTypeConfig
/// <summary>
/// 作者:Kylin
/// 时间:2014.03.27
/// 描述:撤销产品级别配置
/// </summary>
/// <param name="model"></param>
/// <param name="loginUserId"></param>
/// <returns></returns>
public static bool CancelProductCourseTypeConfig(ProductCourseTypeConfig model, int loginUserId)
{
using (var edb = new EmeEntities())
{
try
{
var modelObj = edb.ProductCourseTypeConfig.SingleOrDefault(p => p.Id == model.Id && p.Status == ConvertEnum.StatusTypeForActive);
edb.Entry(modelObj).State = EntityState.Deleted;
var result = edb.SaveChanges() > 0;
return result;
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("ProductBLL-CancelProductCourseTypeConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = loginUserId,
CreateTime = DateTime.Now
});
return false;
}
}
}
示例15: CheckContractFrozenDetail
/// <summary>
/// 作者:Vincen
/// 时间:2014.07.15
/// 描述:检查合同冻结详情
/// </summary>
/// <returns></returns>
public static bool CheckContractFrozenDetail()
{
try
{
using (var edb = new EmeEntities())
{
using (var tran = new TransactionScope())
{
foreach (var detail in
edb.ContractFrozenDetail.Where(
p => p.Status == ConvertEnum.StatusTypeForActive && p.EndDate < DateTime.Now))
{
// 更新合同详情信息
var contractDetail = detail.ContractDetail;
contractDetail.ContractStatusType = (contractDetail.EndDate < DateTime.Now) ? ConvertEnum.ContractStatusTypeForOver : ConvertEnum.ContractStatusTypeForExcute;
edb.Entry(contractDetail).State = EntityState.Modified;
// 更新冻结详情信息 ( 将处理完的数据设为无效 )
detail.UpdateTime = DateTime.Now;
detail.Remark = "系统自动解冻";
detail.Status = ConvertEnum.StatusTypeForInactive;
edb.Entry(detail).State = EntityState.Modified;
}
var result = edb.SaveChanges() > 0;
tran.Complete();
return result;
}
}
}
catch (Exception e)
{
// 异常日志消息队列
Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
{
ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
Message = string.Format("StudentBLL-CheckContractFrozenDetail:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
IsTreat = false,
CreateBy = null,
CreateTime = DateTime.Now
});
return false;
}
}