Beispiel #1
0
        public bool Insert(Receta item, Session session = null)
        {
            //LoggerFactory.CreateLog().Start();
            var committed = 0;

            try
            {
                //if (session != null)
                //    _repositoryReceta.UnitOfWork.SetConnectionDb(session.ConnectionString);

                if (item == null)
                {
                    throw new ArgumentNullException("item");
                }

                var validator = EntityValidatorFactory.CreateValidator();
                if (validator.IsValid(item))
                {
                    // Domain Services?
                    //_repositoryReceta.Insert(Mapper.Map<Dominio.Entidades.Receta>(item));
                    _repositoryReceta.Insert(item);
                    committed = _unitOfWorkAsync.SaveChanges();
                }
                else
                {
                    throw new ApplicationValidationErrorsException(validator.GetInvalidMessages(item));
                }
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(ex);
            }

            //LoggerFactory.CreateLog().Stop();
            return(committed > 0);
        }