Пример #1
0
        public async Task <Role> Create(Role model)
        {
            _context.Add(model);
            await _context.SaveChangesAsync();

            return(model);
        }
Пример #2
0
        public async Task <User> Create(User model)
        {
            // We convert the password into an SHA1 hash
            model.Password = Cryptography.Sha1(model.Password);

            _context.Add(model);
            await _context.SaveChangesAsync();

            return(model);
        }
Пример #3
0
        public async Task <Subscription> Create(Subscription model)
        {
            var existingSubscription = _context.Subscription.FirstOrDefault(x => x.RouteId == model.RouteId && x.UserId == model.UserId);

            if (existingSubscription != null)
            {
                return(existingSubscription);
            }

            _context.Subscription.Add(model);
            await _context.SaveChangesAsync();

            return(model);
        }