public virtual void Update(int id, TEntity obj) { //DbSet.Find(id); if (Db.Entry(obj).State == EntityState.Detached) { Db.Set <TEntity>().Attach(obj); } Db.Entry(obj).State = EntityState.Modified; }
public async Task <IActionResult> PutEmpleado(long id, Empleado empleado) { if (id != empleado.Id) { return(BadRequest()); } _context.Entry(empleado).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmpleadoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUsuario(int id, Usuario usuario) { if (id != usuario.Id) { return(BadRequest()); } _context.Entry(usuario).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsuarioExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCategoria(int id, Categoria categoria) { if (id != categoria.id_categoria) { return(BadRequest()); } _context.Entry(categoria).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoriaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// 更新权限信息 /// </summary> /// <param name="id">权限编号</param> /// <param name="permission">权限信息</param> /// <returns>写入基础数据库的状态项数</returns> public async Task <HttpResponseMessage> Update(int id, Permission permission) { permission.PermissionId = id; _db.Entry(permission).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, Json(result))); }
/// <summary> /// 更新服务信息 /// </summary> /// <param name="id">服务编号</param> /// <param name="service">服务信息</param> /// <returns>写入基础数据库的状态项数</returns> public async Task <HttpResponseMessage> Update(int id, Service service) { service.ServiceId = id; _db.Entry(service).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, Json(result))); }
/// <summary> /// 更新角色信息 /// </summary> /// <param name="id">角色编号</param> /// <param name="role">角色信息</param> /// <returns>写入基础数据库的状态项数</returns> public async Task <HttpResponseMessage> Update(int id, Role role) { role.RoleId = id; role.UpdateTime = DateTime.Now; _db.Entry(role).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, Json(result))); }
/// <summary> /// 更新用户组信息 /// </summary> /// <param name="id">用户组编号</param> /// <param name="userGroup">用户组信息</param> /// <returns>写入基础数据库的状态项数</returns> public async Task <HttpResponseMessage> Update(int id, UserGroup userGroup) { userGroup.UserGroupId = id; userGroup.UpdateTime = DateTime.Now; _db.Entry(userGroup).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, Json(result))); }
public void GrabarValor(TasaCambioDiaria tasaCambioDiaria, int paso) { int result = db.TasaCambioDiaria.Where(c => c.Fecha == tasaCambioDiaria.Fecha).Count(); if (result == 0) { tasaCambioDiaria.Proceso = tasaCambioDiaria.Proceso; tasaCambioDiaria.Actualizado = paso; db.TasaCambioDiaria.Add(tasaCambioDiaria); db.SaveChanges(); ActualizarTodasBasesDatos act = new ActualizarTodasBasesDatos(); List <BasesDatos> lista = new List <BasesDatos>(); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas4", RptDS = "sql5017.site4now.net", password = "******", usuario = "DB_A42167_Pruebas4_admin" }); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas2", RptDS = "sql5020.site4now.net", password = "******", usuario = "DB_A42167_Pruebas2_admin" }); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas3", RptDS = "sql5016.site4now.net", password = "******", usuario = "DB_A42167_Pruebas3_admin" }); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas", RptDS = "sql5027.site4now.net", password = "******", usuario = "DB_A42167_Pruebas_admin" }); act.ActTasaCambio(lista, tasaCambioDiaria); } else { TasaCambioDiaria obj = db.TasaCambioDiaria.First(c => c.Fecha == tasaCambioDiaria.Fecha); obj.Compra = tasaCambioDiaria.Compra; obj.Venta = tasaCambioDiaria.Venta; obj.Actualizado = paso; if (obj.Compra != tasaCambioDiaria.Compra || obj.Venta != tasaCambioDiaria.Venta) { obj.Fecha = tasaCambioDiaria.Fecha; obj.Proceso = "Update-Automatico"; db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); ActualizarTodasBasesDatos act = new ActualizarTodasBasesDatos(); List <BasesDatos> lista = new List <BasesDatos>(); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas4", RptDS = "sql5017.site4now.net", password = "******", usuario = "DB_A42167_Pruebas4_admin" }); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas2", RptDS = "sql5020.site4now.net", password = "******", usuario = "DB_A42167_Pruebas2_admin" }); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas3", RptDS = "sql5016.site4now.net", password = "******", usuario = "DB_A42167_Pruebas3_admin" }); lista.Add(new BasesDatos { ID = 1, NombreBD = "DB_A42167_Pruebas", RptDS = "sql5027.site4now.net", password = "******", usuario = "DB_A42167_Pruebas_admin" }); act.ActTasaCambio(lista, tasaCambioDiaria); } } }
public ActionResult Edit([Bind(Include = "Id,Fecha,Compra,Venta,Proceso,Actualizado")] TasaCambioDiaria tasaCambioDiaria) { if (ModelState.IsValid) { db.Entry(tasaCambioDiaria).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tasaCambioDiaria)); }
public void Update(int id, Entity entity) { try { _sqlServerContext.Entry(entity).State = EntityState.Modified; _sqlServerContext.SaveChanges(); } catch (Exception e) { throw e; } }
public virtual void Remove(Guid id) { using (SqlServerContext entityContext = ContextCreator()) { TEntity entity = entityContext.Set <TEntity>().Find(id); if (entity == null) { return; } entityContext.Entry(entity).State = EntityState.Deleted; entityContext.SaveChanges(); } }
public T Update(T item) { var result = dataset.SingleOrDefault(p => p.Id.Equals(item.Id)); if (result != null) { try { _context.Entry(result).CurrentValues.SetValues(item); _context.SaveChanges(); return(result); } catch (Exception e) { throw; } } return(null); }
public async Task <HttpResponseMessage> Update(int id, Tenant tenant) { if (await _db.User.AnyAsync(x => x.UserId == id)) { Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"User {id} does not exist."); } if (tenant?.TenantDetail == null) { Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Lack of Tenant information."); } tenant.TenantId = id; tenant.UpdateTime = DateTime.Now; _db.Entry(tenant).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(result))); }
public async Task <HttpResponseMessage> Update(int id, User user) { if (await _db.User.AnyAsync(x => x.UserId == id)) { Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"User {id} does not exist."); } if (user?.UserDetail == null) { Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Lack of user information."); } user.UserId = id; user.Token = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{user.UserDetail.UserPrincipalName}:{user.UserDetail.Password}")); user.UpdateTime = DateTime.Now; _db.Entry(user).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(result))); }
public T Update(T item) { try { if (!Exist(item.Id)) { return(null); } var result = dataset.SingleOrDefault(p => p.Id.Equals(item.Id)); _context.Entry(result).CurrentValues.SetValues(item); _context.SaveChanges(); return(item); } catch (Exception ex) { throw ex; } }
public T Update(T entity) { if (!Exist(entity.Id)) { return(null); } var result = dbSet.SingleOrDefault(s => s.Id.Equals(entity.Id)); try { _context.Entry(result).CurrentValues.SetValues(entity); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(entity); }
public User RefreshUserInfo(User user) { if (!_context.User.Any(p => p.Id.Equals(user.Id))) { return(null); } var result = _context.User.SingleOrDefault(p => p.Id.Equals(user.Id)); if (result != null) { try { _context.Entry(result).CurrentValues.SetValues(user); _context.SaveChanges(); return(result); } catch (Exception e) { throw; } } return(result); }
public T Update(T item) { if (!Exists(item.Id)) { return(null); } var result = dataSet.SingleOrDefault(i => i.Id.Equals(item.Id)); try { sqlServerContext.Entry(result).CurrentValues.SetValues(item); sqlServerContext.SaveChanges(); } catch (Exception ex) { throw ex; } return(item); }
public T Update(T obj) { if (!Exists(obj.Id)) { return(null); } T result = dataSet.SingleOrDefault(prop => prop.Id.Equals(obj.Id)); try { _context.Entry(result).CurrentValues.SetValues(obj); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(obj); }
public async Task <HttpResponseMessage> Update(Enterprise enterprise) { HttpResponseMessage response; if (enterprise.EnterpriseId == null) { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"The EnterpriseId is required."); } else if (!ModelState.IsValid) { response = Request.CreateResponse(HttpStatusCode.BadRequest, JsonConvert.SerializeObject(ModelState.ExpendErrors())); } else { _db.Entry(enterprise).State = EntityState.Modified; var result = await _db.SaveChangesAsync(); response = Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(result)); } return(response); }
public async Task <HttpResponseMessage> Update(User user) { HttpResponseMessage response; if (user.UserId == null) { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"The UserId is required."); } else if (!ModelState.IsValid) { response = Request.CreateResponse(HttpStatusCode.BadRequest, JsonConvert.SerializeObject(ModelState.ExpendErrors())); } else { _db.Entry(user).State = EntityState.Modified; user.Token = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{user.UserName}:{user.Password}")); user.Password = Base64Helper.EncodeBase64(user.Password); var result = await _db.SaveChangesAsync(); response = Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(result)); } return(response); }
public async Task Update(T obj) { context.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await context.SaveChangesAsync(); }
public void Update(Department department) { context.Entry(department).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); }
public void Update(T obj) { context.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); }
public void Create(TEntity obj) { context.Entry(obj).State = EntityState.Added; context.SaveChanges(); }
public virtual void Create(TEntity entity) { sqlContext.Entry(entity).State = EntityState.Added; sqlContext.SaveChanges(); }
public void Insert(T obj) { context.Entry(obj).State = EntityState.Added; context.SaveChanges(); }
public void Atualizar(Livro obj) { _context.Entry(obj).State = EntityState.Modified; _context.SaveChanges(); }
public virtual void Insert(TEntity entity) { context.Entry(entity).State = EntityState.Added; context.SaveChanges(); }