public async Task deleteAsync(int ID)
        {
            try
            {
                var trafficUpdate = await _context.TrafficUpdates.FindAsync(ID);

                _context.TrafficUpdates.Remove(trafficUpdate);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task deleteAsync(int ID)
        {
            try
            {
                var bt = await _context.BrainTeasers.FindAsync(ID);

                _context.BrainTeasers.Remove(bt);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public async Task deleteAsync(int ID)
        {
            try
            {
                var contact = await _context.Contacts.FindAsync(ID);

                _context.Contacts.Remove(contact);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public async Task deleteAsync(int ID)
        {
            try
            {
                var vacancy = await _context.Vacancies.FindAsync(ID);

                _context.Vacancies.Remove(vacancy);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        public async Task deleteAllByIDAsync(int BTID)
        {
            try
            {
                var answers = await _context.BrainTeaserAnswers.Where(x => x.BrainTeaserID == BTID).ToListAsync();

                _context.BrainTeaserAnswers.RemoveRange(answers);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 6
0
        public async Task deleteAsync(int ID)
        {
            try
            {
                var article = await _context.Articles.FindAsync(ID);

                _context.Articles.Remove(article);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task deleteAllByIDAsync(int ID)
        {
            try
            {
                var comments = await _context.TrafficComments.Where(x => x.TrafficUpdateID == ID).ToListAsync();

                _context.TrafficComments.RemoveRange(comments);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task deleteAllByIDAsync(int ID)
        {
            try
            {
                var like = await _context.CommentLikes.FindAsync(ID);

                _context.CommentLikes.Remove(like);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 9
0
        public async Task <Response> insertAsync(Privilege data)
        {
            var priv = await _context.Privileges.Where(x => x.Entity == data.Entity && x.Action == data.Action).FirstOrDefaultAsync();

            if (priv != null)
            {
                return new Response {
                           status = false, Result = "Permission already exists"
                }
            }
            ;


            Privilege privilege;

            try
            {
                privilege = new Privilege
                {
                    DisplayName = data.Action + " " + data.Entity,
                    Name        = data.Action + data.Entity,
                    Action      = data.Action,
                    Entity      = data.Entity
                };

                await _context.Privileges.AddAsync(privilege);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new Response {
                status = true, Result = "Permission was created successfully"
            });
        }
        public async Task <bool> insertListAsync(List <RolePrivilege> data)
        {
            try
            {
                await _context.RolePrivileges.AddRangeAsync(data);

                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        public async Task <bool> ApproveUser(int ID)
        {
            var user = await _context.AppUsers.FindAsync(ID);

            try
            {
                user.IsActive = true;
                _context.AppUsers.Update(user);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(true);
        }
Esempio n. 12
0
        public async Task <int> SaveUserRoleAsync(UserRole data)
        {
            try
            {
                var userRole = new UserRole
                {
                    DateCreated = DateTime.Now,
                    RoleID      = data.RoleID,
                    UserID      = data.UserID,
                    UserCreated = data.UserCreated
                };
                await _context.UserRoles.AddAsync(userRole);

                await _context.SaveChangesAsync();

                return(userRole.ID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }