public bool UpdateResourceEntity(IResourceEdit model, Resource entity) { if (model is TechniqueEdit) { var technique = (TechniqueEdit)model; UpdateTechniqueResourceEntity(technique, (TechniqueResource)entity, out bool wasFileChanged); return(wasFileChanged); } else if (model is EnsembleEdit) { var ensemble = (EnsembleEdit)model; UpdateEnsembleResourceEntity(ensemble, (EnsembleResource)entity, out bool wasFileChanged); return(wasFileChanged); } else { var theory = (TheoryEdit)model; UpdateTheoryResourceEntity(theory, (TheoryResource)entity, out bool wasFileChanged); return(wasFileChanged); } }
//____________________________________________UPDATE public bool UpdateResource(IResourceEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Resources.Find(model.ResourceId); if (entity != null) { if (_resourceHelper.UpdateResourceEntity(model, entity)) { var numberOfChanges = ctx.SaveChanges(); return(numberOfChanges == 4); } else { return(ctx.SaveChanges() == 1); } } return(false); } }