public ActionResult SubscribeListEdit(SubscribeList subscribeList) { if (ModelState.IsValid) { db.Entry(subscribeList).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("SubscribeListIndex")); } return(View(subscribeList)); }
public virtual void Add(T entity) { try { EntityEntry dbEntityEntry = _context.Entry(entity); _context.Set <T>().Add(entity); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <IActionResult> PutAssignments(int id, Assignments assignments) { if (id != assignments.AssignmentId) { return(BadRequest()); } _context.Entry(assignments).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssignmentsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployees(int id, Employees employees) { if (id != employees.EmpId) { return(BadRequest()); } _context.Entry(employees).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,SubScribeId,CompanyId")] Subscribe_Company subscribe_Company) { if (ModelState.IsValid) { db.Entry(subscribe_Company).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subscribe_Company)); }
public ActionResult Edit([Bind(Include = "Id,MessTitle,MessBody,MessTime,IsRead")] SystemMessage systemMessage) { if (ModelState.IsValid) { db.Entry(systemMessage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(systemMessage)); }
public ActionResult Edit([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName,Discriminator,CompanyId,CompanyFullName,ConnectionString")] UserModels user) { if (ModelState.IsValid) { SysContext.Entry(user).State = EntityState.Modified; SysContext.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit([Bind(Include = "Id,DimensionName")] Dimension dimension) { if (ModelState.IsValid) { db.Entry(dimension).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dimension)); }
public ActionResult Edit([Bind(Include = "CompanyNumber,FullName,TelNumber,ShortName,EnglishName,LegalRepresentative,EstablishDate,Email,Address,Url,Logo,Remark")] GroupCompany groupCompany) { if (ModelState.IsValid) { db.Entry(groupCompany).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(groupCompany)); }
public ActionResult Edit([Bind(Include = "Id,Target,TagContent,Tag,RecordTime,RecordPerson,PersonName,TagTitle")] Push push) { if (ModelState.IsValid) { sdb.Entry(push).State = EntityState.Modified; sdb.SaveChanges(); return(RedirectToAction("Index")); } return(View(push)); }
public ActionResult Edit([Bind(Include = "Id,SubscribeName,SQL,IsSQLLegal,IsAvailable,CreateDate")] SubscribeList subscribeList) { if (ModelState.IsValid) { db.Entry(subscribeList).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subscribeList)); }
public ActionResult Close(string id) { using (SystemDbContext mydb = new SystemDbContext()) { List <UserModels> tmp = mydb.Users.Where(p => p.CompanyId.Equals(id)).ToList(); foreach (UserModels user in tmp) { user.IsProved = false; } mydb.Entry(tmp).State = System.Data.Entity.EntityState.Modified; mydb.SaveChanges(); return(RedirectToAction("Index")); } }
public OutputResult Modify([FromForm] Student student) { var oldStudent = dbContext.Students.FirstOrDefault(x => x.StudentID == student.StudentID); if (oldStudent == null) { return(OutputResult.Failed("不存在此学生")); } oldStudent.Name = student.Name; oldStudent.PhoneNumber = student.PhoneNumber; oldStudent.ClassName = student.ClassName; oldStudent.SubjectName = student.SubjectName; dbContext.Entry(oldStudent).State = EntityState.Modified; if (dbContext.SaveChanges() < 1) { return(OutputResult.Failed("添加失败")); } return(OutputResult.Success()); }
public JsonResult GenerateVerifyCode() { var PhoneNumber = Request["PhoneNumber"]; string code = (new Random().Next(1111, 9999)).ToString(); string content = "盆景办公提醒您,您的验证码为:" + code; //向用户发送验证码 // int rect = sendOnce(PhoneNumber, content); int rect = 1; //短信验证发送失败! if (rect <= 0) { return(Json(new { errorcode = rect })); } using (var vCode = new SystemDbContext()) { var tmp = vCode.VerifyCodes.Find(PhoneNumber); DateTime createTime = System.DateTime.Now; //电话在数据库中已经存在,更新Code和CreateTime以及OverTime就可以 if (tmp != null) { tmp.Code = code; tmp.CreateTime = createTime; tmp.OverTime = createTime.AddSeconds(VerifyCodeOverTimeSeconds); vCode.Entry(tmp).State = System.Data.Entity.EntityState.Modified; vCode.SaveChanges(); } else { VerifyCode tmpCode = new VerifyCode(); tmpCode.Code = code; tmpCode.PhoneNumber = PhoneNumber; tmpCode.CreateTime = createTime; tmpCode.OverTime = createTime.AddSeconds(VerifyCodeOverTimeSeconds); vCode.VerifyCodes.Add(tmpCode); vCode.SaveChanges(); } } return(Json(new { errorcode = "1" })); }
public bool Delete(int id) { try { _systemDb.Entry(new Solicitud { Id = id }).State = EntityState.Deleted; _systemDb.SaveChanges(); } catch (Exception) { return(false); throw; } return(true); }
/// <summary> /// 针对某一个电话号码发送验证码 /// </summary> /// <param name="PhoneNumber">要发送验证码的手机号</param> /// <returns>大于0说明发送成功,否则是失败</returns> public int sendVerifyCode(string PhoneNumber) { // this.Code = (new Random().Next(1111, 9999)).ToString(); this.Code = "1984"; string content = this.Message + this.Code; //向用户发送验证码 // int rect = sendOnce(PhoneNumber, content); int rect = 1; //短信验证发送失败! if (rect <= 0) { return(rect); } using (var vCode = new SystemDbContext()) { VerifyCode tmp = vCode.VerifyCodes.Find(PhoneNumber); DateTime createTime = System.DateTime.Now; //电话在数据库中已经存在,说明这个用户已经注册过了,更新信息,照常发送验证码 if (tmp != null) { tmp.Code = Code; tmp.CreateTime = createTime; tmp.OverTime = createTime.AddSeconds(VerifyCodeOverTimeSeconds); vCode.Entry(tmp).State = System.Data.Entity.EntityState.Modified; vCode.SaveChanges(); } else { VerifyCode tmpCode = new VerifyCode(); tmpCode.Code = Code; tmpCode.PhoneNumber = PhoneNumber; tmpCode.CreateTime = createTime; tmpCode.OverTime = createTime.AddSeconds(VerifyCodeOverTimeSeconds); vCode.VerifyCodes.Add(tmpCode); vCode.SaveChanges(); } } return(1); }
public ActionResult Edit([Bind(Include = "CompanyId,FullName,TelNumber,BusinessLicense,UserName,ParentCompany,ParentCompanyId,ShortName,EnglishName,LegalRepresentative,EstablishDate,Email,Address,Url,Logo,LogoType,Remark,IsGroupCompany,GroupCompanyNumber")] Company company, HttpPostedFileBase image) { if (ModelState.IsValid) { if (image != null) { company.LogoType = image.ContentType; //获取图片类型 company.Logo = new byte[image.ContentLength]; //新建一个长度等于图片大小的二进制地址 image.InputStream.Read(company.Logo, 0, image.ContentLength); //将image读取到Logo中 } if (company.IsGroupCompany == false) { company.GroupCompanyNumber = null; } db.Entry(company).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details")); } return(View(company)); }
public async Task <IActionResult> PutRoles(Roles roles) { _context.Entry(roles).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RolesExists(roles.RoleId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Edit(int id, BazinamSite2.Areas.Admin.ViewModel.News _new) { try { // TODO: Add update logic here var editedNews = new BazinamSite2.Models.News() { NewsID = id, Title = _new.Title, Content = _new.Content, ReleaseDate = DateTime.Parse(_new.ReleaseDate) }; using (SystemDbContext context = new SystemDbContext()) { context.Entry(editedNews).State = System.Data.Entity.EntityState.Modified; await context.SaveChangesAsync(); } return(RedirectToAction("/Index")); } catch { return(View()); } }
public ActionResult Audit(string id) { /** * 生成企业的数据库名称 * */ string CompanyDbName = "Bonsaii" + id; var flag1 = CreateDbForCompany(CompanyDbName); var tmp = db.Users.Where(p => p.CompanyId.Equals(id)).Single(); tmp.IsProved = true; db.Entry(tmp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var flag2 = CreateCompanyTables(tmp.ConnectionString); //创建该企业用户的私有数据表 if (flag1 && flag2) { return(RedirectToAction("Index")); } else { return(View("Error")); } }