Пример #1
0
        public bool Update(AlbumBE entity)
        {
            var dbContext = new DBContext();

            try
            {
                var           dataSet       = new DataSet();
                var           parameters    = Array.Empty <SqlParameter>();
                PermissionDAL permissionDAL = new PermissionDAL();

                parameters = new SqlParameter[3];

                parameters[0] = dbContext.CreateParameters("@name", entity.Name);
                parameters[1] = dbContext.CreateParameters("@imgKey", entity.ImgKey);
                parameters[2] = dbContext.CreateParameters("@albumID", entity.Id);



                if (dbContext.Write("UpdateAlbum", parameters) > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
Пример #2
0
        public bool Update(SongBE entity)
        {
            var dbContext = new DBContext();

            try
            {
                var           dataSet       = new DataSet();
                var           parameters    = Array.Empty <SqlParameter>();
                PermissionDAL permissionDAL = new PermissionDAL();

                parameters = new SqlParameter[4];

                parameters[0] = dbContext.CreateParameters("@songID", entity.Id);
                parameters[1] = dbContext.CreateParameters("@name", entity.Name);
                parameters[2] = entity.Album == null ? (dbContext.CreateNullParameters("@albumID")) : dbContext.CreateParameters("@albumID", entity.Album.Id);
                parameters[3] = dbContext.CreateParameters("@categoryID", entity.Category.Id);



                if (dbContext.Write("UpdateSong", parameters) > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
Пример #3
0
        public bool UpdateDictionary(LanguageViewModel languageViewModel)
        {
            var dbContext = new DBContext();

            try
            {
                var           dataSet       = new DataSet();
                var           parameters    = Array.Empty <SqlParameter>();
                PermissionDAL permissionDAL = new PermissionDAL();

                parameters = new SqlParameter[3];

                parameters[0] = dbContext.CreateParameters("@languageID", languageViewModel.Id);
                parameters[1] = dbContext.CreateParameters("@key", languageViewModel.Dictionary.First().Key);
                parameters[2] = dbContext.CreateParameters("@value", languageViewModel.Dictionary.First().Value);



                if (dbContext.Write("UpdateDictionary", parameters) > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
Пример #4
0
        public bool Update(ClaimBE entity)
        {
            var dbContext = new DBContext();

            try
            {
                var           dataSet       = new DataSet();
                var           parameters    = Array.Empty <SqlParameter>();
                PermissionDAL permissionDAL = new PermissionDAL();

                parameters = new SqlParameter[2];

                parameters[0] = dbContext.CreateParameters("@claimID", entity.Id);
                parameters[1] = dbContext.CreateParameters("@stateID", entity.State.Id);



                if (dbContext.Write("ChangeState", parameters) > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
Пример #5
0
        public bool SetUserPermission(UserBE entity)
        {
            var dbContext = new DBContext();

            bool result = false;

            try
            {
                dbContext.BeginTran();

                PermissionDAL per = new PermissionDAL();

                if (per.DeleteUserPermission(entity, dbContext))
                {
                    result = per.SetUserPermission(entity, dbContext);
                }


                if (result)
                {
                    dbContext.CommitTran();
                    return(result);
                }

                dbContext.RollBackTran();
                return(result);
            }
            catch (Exception)
            {
                return(result);
            }
        }
Пример #6
0
        public bool AddPermissionGroup(PermissionBE entity, PermissionBE parent)
        {
            var dbContext = new DBContext();

            try
            {
                var           dataSet       = new DataSet();
                var           parameters    = Array.Empty <SqlParameter>();
                PermissionDAL permissionDAL = new PermissionDAL();

                parameters = new SqlParameter[2];

                parameters[0] = dbContext.CreateParameters("@permissionID", entity.Id);
                parameters[1] = dbContext.CreateParameters("@parentID", parent.Id);



                if (dbContext.Write("AddPermissionGroup", parameters) > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
Пример #7
0
        public Guid Add(UserBE entity)
        {
            var dbContext = new DBContext();

            try
            {
                var dataSet    = new DataSet();
                var parameters = Array.Empty <SqlParameter>();


                var userguid = Guid.NewGuid();
                parameters = new SqlParameter[11];

                parameters[0]  = dbContext.CreateParameters("@imgKey", !string.IsNullOrEmpty(entity.ImgKey) ? entity.ImgKey : null);
                parameters[1]  = dbContext.CreateParameters("@userName", entity.UserName);
                parameters[2]  = dbContext.CreateParameters("@lastName", entity.LastName);
                parameters[3]  = dbContext.CreateParameters("@name", entity.Name);
                parameters[4]  = dbContext.CreateParameters("@languageID", entity.Language.Id);
                parameters[5]  = dbContext.CreateParameters("@email", !string.IsNullOrEmpty(entity.Email) ? entity.Email : null);
                parameters[6]  = dbContext.CreateParameters("@password", entity.Password);
                parameters[8]  = dbContext.CreateParameters("@artistName", !string.IsNullOrEmpty(entity.ArtistName) ? entity.ArtistName : null);
                parameters[7]  = dbContext.CreateParameters("@serviceID", entity.Contract.Service.Id == Guid.Empty ? Guid.Empty : entity.Contract.Service.Id);
                parameters[9]  = dbContext.CreateParameters("@userid", userguid);
                parameters[10] = dbContext.CreateParameters("@contractID", entity.Contract.Service.Id == Guid.Empty ? Guid.Empty : Guid.NewGuid());

                dbContext.BeginTran();
                if (dbContext.Write("AddUser", parameters) > 0)
                {
                    entity.Id = userguid;
                    PermissionDAL per       = new PermissionDAL();
                    bool          resultper = per.SetUserPermission(entity, dbContext);

                    if (resultper)
                    {
                        dbContext.CommitTran();
                        return(userguid);
                    }
                }
                dbContext.RollBackTran();
                return(Guid.Empty);
            }
            catch (Exception ex)
            {
                dbContext.RollBackTran();
                throw new Exception(Messages.Generic_Error);
            }
        }
Пример #8
0
        public bool DeleteUserPermission(UserBE entity, DBContext dbCon)
        {
            try
            {
                var     dataSet    = new DataSet();
                var     parameters = Array.Empty <SqlParameter>();
                bool    result     = false;
                UserDAL userDAL    = new UserDAL();


                try
                {
                    var           permissions = this.GetUserPermissions(entity);
                    PermissionDAL per         = new PermissionDAL();

                    foreach (var perold in permissions)
                    {
                        var pernew = entity.Permissions.Where(p => p.Name == perold.Name).FirstOrDefault();
                        if (pernew == null && perold.Name != "Login")
                        {
                            parameters = new SqlParameter[2];

                            parameters[1] = dbCon.CreateParameters("@userID", entity.Id);
                            parameters[0] = dbCon.CreateParameters("@permissionID", perold.Id);


                            return((dbCon.Write("DeleteUserPermission", parameters) > 0) ? true : false);
                        }
                    }

                    return(result);
                }
                catch (Exception ex)
                {
                    throw ex;
                }



                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }