本文整理汇总了C#中LoveBank.Core.MSData.LoveBankDBContext.Add方法的典型用法代码示例。如果您正苦于以下问题:C# LoveBankDBContext.Add方法的具体用法?C# LoveBankDBContext.Add怎么用?C# LoveBankDBContext.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoveBank.Core.MSData.LoveBankDBContext
的用法示例。
在下文中一共展示了LoveBankDBContext.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppPostHelperMoney
/// <summary>
/// 必传参数
/// AppUserId/
/// SeekHelperId/
/// Money:捐助的金额
/// BankCard:支付卡号
/// Desc:捐赠寄语
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public ActionResult AppPostHelperMoney(SeekHelperRecorde entity)
{
JsonMessage ret = new JsonMessage();
entity.AddTime = DateTime.Now;
using (LoveBankDBContext db = new LoveBankDBContext())
{
var t_a = db.T_SeekHelper;
var t_sr = db.T_SeekHelperRecorde;
var t_u = db.T_AppUser; ;
//SeekHelper sh = t_a.Find(entity.SeekHelperId);
AppUser au = t_u.Find(entity.AppUserId);
entity.Name = au.Name;
entity.Phone = au.Phone;
entity.AppUserType = au.Type;
db.Add(entity);
db.SaveChanges();
ret.Status = true;
ret.Info = "捐助成功";
return Json(ret);
}
}
示例2: AppPostTSAdd
public ActionResult AppPostTSAdd(Supervise entity)
{
JsonMessage retJson = new JsonMessage();
try
{
using (LoveBankDBContext db = new LoveBankDBContext())
{
entity.AddTime = DateTime.Now;
db.Add(entity);
db.SaveChanges();
retJson.Status = true;
retJson.Info = "新增成功";
}
return Json(retJson);
}
catch (Exception ex)
{
retJson.Status = false;
retJson.Data = ex.Message + ex.TargetSite;
return Json(retJson);
}
}
示例3: AppPostAddSuggestion
public ActionResult AppPostAddSuggestion(Suggestion entity)
{
JsonMessage retJson = new JsonMessage();
using (LoveBankDBContext db = new LoveBankDBContext())
{
if (entity.AddUser>0)
{
var addUserModel = (from v in db.T_Vol where v.ID == entity.AddUser select new { v.DepId, v.Phone, v.RealName }).FirstOrDefault();
entity.DepId = addUserModel.DepId;
entity.AddUserName = addUserModel.RealName;
entity.AddUserPhone = addUserModel.Phone;
}
entity.AddTime = DateTime.Now;
db.Add<Suggestion>(entity);
db.SaveChanges();
retJson.Status = true;
retJson.Info = "新增成功";
}
return Json(retJson);
}
示例4: PostAddSupervise
public ActionResult PostAddSupervise(Supervise entity)
{
JsonMessage retJson = new JsonMessage();
entity.DepId = BaseWebSiteConifg.DeptId;
using (LoveBankDBContext db = new LoveBankDBContext())
{
if (User != null)
{
entity.AddUserName = User.RealName;
entity.AddUserPhone = User.Phone;
entity.AddUser = User.ID;
}
entity.AddTime = DateTime.Now;
db.Add<Supervise>(entity);
db.SaveChanges();
retJson.Status = true;
retJson.Info = "提交成功";
}
return Json(retJson);
}
示例5: PostEdit
public ActionResult PostEdit(UnitInfoAbout parm)
{
using (LoveBankDBContext db = new LoveBankDBContext())
{
var t_wsn = db.T_UnitInfoAbout;
UnitInfoAbout model= (from w in t_wsn where w.DeptId == AdminUser.DeptId select w).FirstOrDefault();
if (model==null)
{
parm.AddUserId = AdminUser.ID;
parm.DeptId = AdminUser.DeptId;
parm.AddTime = DateTime.Now;
parm.State = RowState.有效;
db.Add(parm);
db.SaveChanges();
return Success("保存成功");
}
//UnitInfoAbout model = t_wsn.Find(parm.ID);
model.Sort = parm.Sort;
model.Address = parm.Address;
model.Title = parm.Title;
model.Content = parm.Content;
model.EMail = parm.EMail;
model.Fax = parm.Fax;
model.Type = parm.Type;
model.UnitName = parm.UnitName;
db.Update(model);
db.SaveChanges();
return Success("保存成功");
}
}
示例6: PostRegister
public ActionResult PostRegister(string phone, string Password, string Validate)
{
//if (!phone.MatchAndNotNull(RegularUtil.Phone)) return Error("手机号错误");
var cookie = Request.Cookies["PostRegister_valicode"];
if (cookie == null)
{
return Error("验证码错误.");
}
var cookieValue = cookie.Value;
if (Validate.Hash().Hash() != cookieValue)
{
ModelState.AddModelError("", "验证码错误!");
return Error("验证码错误.");
}
try
{
Vol model = new Vol();
model.RealNameState = 1;
model.State = 1;
model.Type = "志愿者";
model.LoveBankScore = 0;
model.Score = 0;
model.Source = 2;//来源未2标示是爱心银行网站
model.Phone = phone;
model.PassWord = Password;
using (LoveBankDBContext db = new LoveBankDBContext())
{
var tv = db.T_Vol;
if (tv.Count(x => x.Phone == model.Phone) > 0)
{
return Error("该手机号已经存在");
}
db.Add<Vol>(model);
db.SaveChanges();
}
_authenticationService.SignIn(model.ID.ToString(), false);
ViewData["Jump"] = Url.Action("Index", "Home");
//return Redirect("~/");
return RedirectToAction("RegSuccess");
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
示例7: PostAdd
public ActionResult PostAdd(CServiceCenterInfo model)
{
#region 初始化参数
model.AddUserId = AdminUser.ID;
model.DeptId = AdminUser.DeptId;
model.AddTime = DateTime.Now;
model.State = RowState.有效;
#endregion
using (LoveBankDBContext db = new LoveBankDBContext())
{
db.Add(model);
db.SaveChanges();
return Success("添加成功");
}
}
示例8: PostAddTeamProjectSummary
public ActionResult PostAddTeamProjectSummary(TeamProjectSummaryModel parm)
{
TeamProjectSummary model = new TeamProjectSummary();
model.AddTime = DateTime.Now;
model.AddUserId = AdminUser.ID;
model.State = RowState.有效;
model.Guid = Guid.NewGuid().ToString();
model.SubTitle = parm.SubTitle;
model.TeamProjectId = parm.TeamProjectId;
model.Desc = parm.Desc;
//foreach (var item in parm.SourceFileList)
//{
// item.Guid = model.Guid;
// item.AddTime = DateTime.Now;
//}
using (LoveBankDBContext db = new LoveBankDBContext())
{
db.Add<TeamProjectSummary>(model);
db.SaveChanges();
//db.T_SourceFile.AddRange(parm.SourceFileList);
//db.SaveChanges();
return Success("新增成功");
}
}
示例9: PostAddTeamPojectStation
public ActionResult PostAddTeamPojectStation(TeamPojectStation parm)
{
parm.AddTime = DateTime.Now;
parm.AddUserId = AdminUser.ID;
parm.State = RowState.有效;
using (LoveBankDBContext db = new LoveBankDBContext())
{
db.Add<TeamPojectStation>(parm);
db.SaveChanges();
}
return Success("新增成功");
}
示例10: PostAdd
public ActionResult PostAdd(MachineModuleShowManageModel parm)
{
#region 初始化参数
MachineModuleShowManage model = new MachineModuleShowManage();
model.AddTime = DateTime.Now;
model.AddUserId = AdminUser.ID;
model.State = RowState.有效;
model.Guid = Guid.NewGuid().ToString();
model.DeptId = parm.DeptId;
model.IconUrl = parm.IconUrl;
model.LinkUrl = parm.LinkUrl;
model.ModuleKey = parm.ModuleKey;
model.Name = parm.Name;
model.Sort = parm.Sort;
model.Type = parm.Type;
model.Icon = parm.Icon;
foreach (var item in parm.SourceFileList)
{
item.Guid = model.Guid;
item.AddTime = DateTime.Now;
}
#endregion
using (LoveBankDBContext db = new LoveBankDBContext())
{
db.Add(model);
db.SaveChanges();
db.T_SourceFile.AddRange(parm.SourceFileList);
db.SaveChanges();
return Success("添加成功");
}
}
示例11: PostAdd
public ActionResult PostAdd(Vol model, string volHeadImgBase64)
{
if (!string.IsNullOrEmpty(volHeadImgBase64))
{
byte[] headerimgByte = Convert.FromBase64String(volHeadImgBase64.Substring(23));
model.VolHeadImg = headerimgByte;
}
using (LoveBankDBContext db = new LoveBankDBContext())
{
var tv = db.T_Vol;
if (tv.Count(x => x.Phone == model.Phone) > 0)
{
return Success("该手机号已经存在");
}
model.RealNameState = 1;
model.State = 1;
model.Type = "志愿者";
model.LoveBankScore = 0;
model.Score = 0;
model.Source = 1;//来源未1标示是爱心银行
model.AddUserId = AdminUser.ID;
db.Add<Vol>(model);
db.SaveChanges();
return Success("操作成功");
}
}
示例12: App_ExchangeProduct
/// <summary>
/// 兑换产品:
/// 参数:MacineCode机器Id
/// LoveBankProductId:被兑换产品Id
/// MacineCode:被兑换机器唯一码
/// Type: 账号登陆兑换 = 0, 二维码登陆兑换 = 1, NFC登陆兑换 = 2
/// ExChangeCount:兑换数量,默认值是:1
/// AddUserId:兑换人的用户ID
/// Address(可选,兑换的地址)
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public ActionResult App_ExchangeProduct(LoveBankProductExchangeLog entity)
{
entity.AddTime = DateTime.Now;
entity.ExChangeCount = entity.ExChangeCount <= 0 ? 1 : entity.ExChangeCount;
entity.Source = "爱心银行";
entity.State = 0;
JsonMessage retJson = new JsonMessage();
using (LoveBankDBContext db = new LoveBankDBContext())
{
var t_p = db.T_Product;
var t_v = db.T_Vol;
var t_d = db.T_Department;
var t_m = db.T_Machine;
Product productModel = t_p.Find(entity.LoveBankProductId);
if (productModel == null)
{
retJson.Status = false;
retJson.Info = "产品不存在";
return Json(retJson);
}
if (productModel.Count < entity.ExChangeCount)
{
retJson.Status = false;
retJson.Info = "产品数量不足";
return Json(retJson);
}
Vol vol = t_v.Find(entity.AddUserId);
if (vol == null)
{
retJson.Status = false;
retJson.Info = "用户不存在";
return Json(retJson);
}
MachineModel mm = (from m in t_m
where m.MachineCode == entity.MacineCode
select new MachineModel
{
Address = m.Address,
Lat = m.Lat,
Lon = m.Lon,
DeptId = m.DeptId
}).FirstOrDefault();
if (vol.DepId.IndexOf(mm.DeptId) < 0)//判断该机器和用户是否是同一个社区
{
var depName = (from d in t_d where d.Id == mm.DeptId select d.Name).FirstOrDefault();
retJson.Status = false;
retJson.Info = string.Format("抱歉,该终端只服务于{0}用户", depName);
retJson.Data = "-2";
return Json(retJson);
}
if (vol.DepId.IndexOf(productModel.DeptId) < 0)//判断是否属于该社区
{
var depName = (from d in t_d where d.Id == productModel.DeptId select d.Name).FirstOrDefault();
retJson.Status = false;
retJson.Info = string.Format("抱歉,该产品属于{0}", depName);
retJson.Data = "-2";
return Json(retJson);
}
int totalCostScore = entity.CostScore * entity.ExChangeCount;
if (!vol.LoveBankScore.HasValue || vol.LoveBankScore.Value < totalCostScore)
{
retJson.Status = false;
retJson.Info = "积分不足,可用积分:" + vol.LoveBankScore + ".对应产品所需总积分:" + totalCostScore + ".兑换数量:" + entity.ExChangeCount;
return Json(retJson);
}
productModel.Count = productModel.Count - entity.ExChangeCount;//减少兑换数量
db.Update<Product>(productModel);
db.SaveChanges();
entity.Address = mm.Address;
entity.Lat = mm.Lat;
entity.Lon = mm.Lon;
entity.CostScore = productModel.CostScore * entity.ExChangeCount;
db.Add<LoveBankProductExchangeLog>(entity);//保存兑换记录
db.SaveChanges();
//.........这里部分代码省略.........
示例13: PostAdd
public ActionResult PostAdd(SeekHelperModel parm)
{
#region 初始化参数
SeekHelper model = new SeekHelper();
model.AddTime = DateTime.Now;
model.AddUserId = AdminUser.ID;
model.State = RowState.有效;
model.GuidSourceFileHeadImg = Guid.NewGuid().ToString();
model.LinkUrl = parm.LinkUrl;
model.Name = parm.Name;
model.Desc = parm.Desc;
model.EndTime = parm.EndTime;
model.PublicTime = DateTime.Now;
model.TotalMoney = parm.TotalMoney;
model.FinishMoney = parm.FinishMoney;
model.Address = parm.Address;
model.Bank = parm.Bank;
model.Phone = parm.Phone;
model.DeptId = parm.DeptId;
model.BankCard = parm.BankCard;
foreach (var item in parm.SourceFileList)
{
item.Guid = model.GuidSourceFileHeadImg;
item.AddTime = DateTime.Now;
}
#endregion
using (LoveBankDBContext db = new LoveBankDBContext())
{
db.Add(model);
db.SaveChanges();
db.T_SourceFile.AddRange(parm.SourceFileList);
db.SaveChanges();
return Success("添加成功");
}
}
示例14: PostAddTeamProject
public ActionResult PostAddTeamProject(TeamProjectModel parm)
{
#region 初始化参数
//Team model = new Team();
parm.AddTime = DateTime.Now;
parm.AddUserId = AdminUser.ID;
parm.State = RowState.有效;
parm.Guid = Guid.NewGuid().ToString();
#endregion
JsonMessage retJson = new JsonMessage();
using (LoveBankDBContext db = new LoveBankDBContext())
{
db.Add(parm);
db.SaveChanges();
retJson.Status = true;
retJson.Info = "添加成功";
return Json(retJson);
}
}
示例15: PostAdd
public ActionResult PostAdd(Team parm, IList<SourceFile> SourceFileList)
{
#region 初始化参数
//Team model = new Team();
parm.AddTime = DateTime.Now;
parm.AddUserId = AdminUser.ID;
parm.State = TeamState.审核通过;
parm.Guid = Guid.NewGuid().ToString();
foreach (var item in SourceFileList)
{
item.Guid = parm.Guid;
item.AddTime = DateTime.Now;
}
#endregion
JsonMessage retJson = new JsonMessage();
using (LoveBankDBContext db = new LoveBankDBContext())
{
db.Add(parm);
db.SaveChanges();
db.T_SourceFile.AddRange(SourceFileList);
db.SaveChanges();
retJson.Status = true;
retJson.Info = "添加成功";
return Json(retJson);
}
}