public GetContentTypeResponse Get(Guid id) { IContentTypeRepository repo = IoC.Container.Resolve <IContentTypeRepository>(); GetContentTypeResponse response = repo.GetById <GetContentTypeResponse>(id.ToString()); IParameterRepository paramRepo = IoC.Container.Resolve <IParameterRepository>(); response.Parameters = paramRepo.GetByParentId(id, ParameterParentType.ContentType); return(response); }
private void UpdateParameters(Guid contentId, IList <Parameter> parameters, IUnitOfWork uow) { IParameterRepository paramRepo = IoC.Container.Resolve <IParameterRepository>(uow); IList <Parameter> currentParams = paramRepo.GetByParentId(contentId, ParameterParentType.ContentType); foreach (Parameter param in currentParams) { if (parameters.Any(item => item.Id == param.Id)) { continue; } paramRepo.Delete(param.Id.ToString()); } foreach (Parameter param in currentParams) { if (!parameters.Any(item => item.Id == param.Id)) { continue; } Parameter modifiedParam = parameters.FirstOrDefault(item => item.Id == param.Id); param.UpdateFrom(modifiedParam); paramRepo.Update(param); } foreach (Parameter param in parameters) { if (currentParams.Any(item => item.Id == param.Id)) { continue; } //if (param.Id != null && param.Id != Guid.Empty) { continue; } Parameter newParam = new Parameter(); newParam.CreateFrom(param); newParam.ParentType = ParameterParentType.ContentType; newParam.ParentId = contentId; paramRepo.Add(newParam); } }