Example #1
0
        public OperationResult <Guid?> DeleteParameter(Guid?id)
        {
            //Validazione argomenti
            if (!id.HasValue)
            {
                throw new ArgumentNullException(nameof(id));
            }

            //Dichiaro la listsa di risultati di ritorno
            IList <ValidationResult> vResults = new List <ValidationResult>();

            //Definisco l'entità
            Parameter entity = _parameterRepository.Load(id);

            //Eseguo la validazione logica
            vResults = ValidateEntity(entity);

            if (!vResults.Any())
            {
                //Salvataggio su db
                _parameterRepository.Delete(entity);
            }

            //Ritorno i risultati
            return(new OperationResult <Guid?>
            {
                ReturnedValue = null,
                ValidationResults = vResults
            });
        }
 public bool Delete(int id)
 {
     if (string.IsNullOrWhiteSpace(id.ToString()))
     {
         return(status);
     }
     else
     {
         return(iParameterRepository.Delete(id));
     }
 }
 public bool Delete(int id)
 {
     if (string.IsNullOrWhiteSpace(Convert.ToString(id)))
     {
         return(status);
     }
     else
     {
         return(parameter.Delete(id));
     }
 }
        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);
            }
        }
 public bool Delete(int id)
 {
     return(iParameterRepository.Delete(id));
 }