public void UpdateConcept(int graphId, int id, ConceptDto conceptDto) { var actualConcept = winContext.Concepts .Include(c => c.Dependencies) .SingleOrDefault(c => c.Id == id && c.Graph.Id == graphId); if (actualConcept == null) { return; } var concept = conceptDtoToConceptMapping.Map(conceptDto); conceptUpdater.Update(actualConcept, concept); winContext.RemoveRange(actualConcept.Dependencies); foreach (var dependency in winContext.Concepts .Where(c => conceptDto.DependenciesIds.Contains(c.Id)) .ToList()) { actualConcept.Dependencies.Add(dependency); } winContext.SaveChanges(); }
public WorkerDto Update(int id, [FromBody] WorkerDto workerDto) { Worker worker = workerDtoToWorkerMapping.Map(workerDto); Worker actualWorker = alohaContext.Workers .Include(f => f.User) .Include(w => w.Workstation) .ThenInclude(w => w.Floor) .Include(f => f.Photo) .SingleOrDefault(f => f.Id == id); if (workerDto.PhotoUrl != null && workerDto.PhotoUrl != string.Empty) { if (actualWorker.Photo != null) { alohaContext.Remove(actualWorker.Photo); } actualWorker.Photo = FileHelper.GetFileFromBase64(workerDto.PhotoUrl); } workerUpdater.Update(actualWorker, worker); alohaContext.SaveChanges(); return(workerToWorkerDtoMapping.Map(actualWorker)); }
public bool Import(Guid solutionId, IList <Domain.Entity> entities) { if (entities.NotEmpty()) { foreach (var item in entities) { var existEntity = _entityFinder.FindById(item.EntityId); if (existEntity != null) { existEntity.DuplicateEnabled = item.DuplicateEnabled; existEntity.AuthorizationEnabled = item.AuthorizationEnabled; existEntity.LogEnabled = item.LogEnabled; existEntity.LocalizedName = item.LocalizedName; existEntity.BusinessFlowEnabled = item.BusinessFlowEnabled; existEntity.WorkFlowEnabled = item.WorkFlowEnabled; _entityUpdater.Update(existEntity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; item.IsCustomizable = true; item.OrganizationId = _appContext.OrganizationId; _entityCreater.Create(item, false); } //字段 _attributeImporter.Import(solutionId, item, item.Attributes); } } return(true); }
public FloorDto Update(int id, [FromBody] FloorDto floorDto) { Floor floor = floorDtoToFloorMapping.Map(floorDto); Floor actualFloor = dbContext.Floors .Include(f => f.Office) .Include(f => f.Workstations) .Include(f => f.Image) .SingleOrDefault(f => f.Id == id); if (floorDto.ImageUrl != null && floorDto.ImageUrl != string.Empty) { if (actualFloor.Image != null) { dbContext.Remove(actualFloor.Image); } actualFloor.Image = FileHelper.GetFileFromBase64(floorDto.ImageUrl); } floorUpdater.Update(actualFloor, floor); dbContext.SaveChanges(); return(floorToFloorDtoMapping.Map(actualFloor)); }
public OfficeDto Update(int id, [FromBody] OfficeDto officeDto) { Office office = officeDtoToOfficeMapping.Map(officeDto); Office actualOffice = dbContext.Offices .SingleOrDefault(f => f.Id == id); officeUpdater.Update(actualOffice, office); dbContext.SaveChanges(); return(officeToOfficeDtoMapping.Map(actualOffice)); }
public void Update(DbContextBase dbCtx, object e) { var entityType = e.GetType(); if (!_typesToExclude.Any(t => t.IsAssignableFrom(entityType))) { var pi = entityType.GetProperty(_propertyName); if (pi != null) { dbCtx.Entry(e).OriginalValues[_propertyName] = pi.GetValue(e); } } _entityUpdater.Update(dbCtx, e); }
public void UpdateGraph(int id, GraphDto graphDto) { var actualGraph = winContext.Graphs .SingleOrDefault(g => g.Id == id); if (actualGraph == null) { return; } var graph = graphDtoToGraphMapping.Map(graphDto); graphUpdater.Update(actualGraph, graph); winContext.SaveChanges(); }
public IActionResult Post(EditEntityModel model) { if (ModelState.IsValid) { var entity = _entityFinder.FindById(model.EntityId); if (entity == null) { return(NotFound()); } model.IsCustomizable = entity.IsCustomizable; model.CopyTo(entity); _entityUpdater.Update(entity); return(UpdateSuccess(new { id = entity.EntityId })); } return(UpdateFailure(GetModelErrors())); }
public IActionResult EditEntity(EditEntityModel model) { if (ModelState.IsValid) { var entity = _entityFinder.FindById(model.EntityId); model.IsCustomizable = entity.IsCustomizable; model.CopyTo(entity); if (model.EntityGroupId.NotEmpty()) { entity.EntityGroups = model.EntityGroupId.SerializeToJson(); } _entityUpdater.Update(entity); return(UpdateSuccess(new { id = entity.EntityId })); } return(UpdateFailure(GetModelErrors())); }
public WorkstationDto Update(int floorId, int id, [FromBody] WorkstationDto workstationDto) { Workstation workstation = workstationDtoToWorkstationMapping.Map(workstationDto); Workstation actualWorkstation = dbContext.Workstations .Include(w => w.Floor) .Where(w => w.Floor.Id == floorId) .SingleOrDefault(w => w.Id == id); if (actualWorkstation == null) { return(null); } workstationUpdater.Update(actualWorkstation, workstation); dbContext.SaveChanges(); return(workstationToWorkstationDtoMapping.Map(actualWorkstation)); }
internal void Update(object e) { _entityUpdater.Update(this, e); }