Ejemplo n.º 1
0
        public string CreateScribble(Scribble scribble)
        {
            Check.If(scribble).IsNotNull();

            if (scribble.ApplicationReference.IsNullOrEmpty())
                return null;

            var result = _scribbleRepository.CreateOrUpdateScribble(scribble);

            return result ? scribble.ApplicationReference : null;
        }
Ejemplo n.º 2
0
        public bool CreateOrUpdateScribble(Scribble scribble)
        {
            var existingScribble =
                _scribbleContext.Scribbles.Active()
                    .FirstOrDefault(
                        s => s.ApplicationReference == scribble.ApplicationReference && s.Username == scribble.Username);

            //if it already exists, soft delete it.
            if (existingScribble.IsNotNull())
            {
                existingScribble.SoftDelete();
            }

            _scribbleContext.Scribbles.Add(scribble);

            return _scribbleContext.SaveChanges() > 0;
        }