コード例 #1
0
        public async Task <Usersinrole> DeleteAsync(Usersinrole item)
        {
            try
            {
                var validator = new UserRoleDeleteValidator(_ctx);
                item.Validation = validator.Validate(item);
                if (!item.Validation.IsValid)
                {
                    return(await Task.FromResult(item));
                }

                USERSINROLE data = MapToEntity(item);
                _ctx.Entry(data).State = EntityState.Deleted;
                var error = new ValidationFailure("Role", string.Format(ValidationErrorMessage.GenericDBDeleteError, "Role"));
                item.Validation.Errors.Add(error);
                await _ctx.SaveChangesAsync();

                _logger.Log("FATAL", "Delete User in Role", item, error.ErrorMessage);


                return(item);
            }

            catch (Exception ex)
            {
                item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBDeleteError, "Usersinrole");
                _logger.Log("INFO", "Delete User in Role", item, "Successful.");
                return(item);
            }
        }
コード例 #2
0
        public async Task <Applications> DeleteAsync(Applications item)
        {
            var data = await _ctx.APPLICATIONS.FirstOrDefaultAsync(x => x.APPLICATIONID == item.Applicationid);

            data.ISDELETED         = true;
            _ctx.Entry(data).State = EntityState.Modified;
            if (await _ctx.SaveChangesAsync() <= 0)
            {
                var error = new ValidationFailure("Applications", string.Format(ValidationErrorMessage.GenericDBDeleteError, "Applications"));
                item.Validation.Errors.Add(error);
                _logger.Log("FATAL", "Delete Application", item, error.ErrorMessage);
                return(await Task.FromResult <Applications>(item));
            }
            _logger.Log("INFO", "Delete Application", item, "Successful.");
            return(await Task.FromResult <Applications>(MapToDTO(data)));
        }
コード例 #3
0
ファイル: RolesBL.cs プロジェクト: Lester-M-Bautista/tester
        public async Task <Roles> DeleteAsync(Roles item)
        {
            var data = await _ctx.ROLES.FirstOrDefaultAsync(x => x.ROLEID == item.Roleid);

            data.ISDELETED = 1;
            _ctx.ROLES.Remove(data);
            _ctx.Entry(data).State = EntityState.Modified;
            if (await _ctx.SaveChangesAsync() <= 0)
            {
                var error = new ValidationFailure("Role", string.Format(ValidationErrorMessage.GenericDBDeleteError, "Role"));
                item.Validation.Errors.Add(error);
                _logger.Log("FATAL", "Delete Role", item, error.ErrorMessage);
                return(await Task.FromResult <Roles>(item));
            }
            _logger.Log("INFO", "Delete Role", item, "Successful.");
            return(await Task.FromResult <Roles>(MapToDTO(data)));
        }
コード例 #4
0
        public async Task <Permissionsofrole> DeleteAsync(Permissionsofrole item)
        {
            var validator = new RolePermissionDeleteValidator(_ctx);

            item.Validation = validator.Validate(item);
            if (!item.Validation.IsValid)
            {
                return(await Task.FromResult(item));
            }
            PERMISSIONSOFROLE data = MapToEntity(item);

            _ctx.Entry(data).State = EntityState.Deleted;

            if (await _ctx.SaveChangesAsync() <= 0)
            {
                var error = new ValidationFailure("PermissionofRole", string.Format(ValidationErrorMessage.GenericDBDeleteError, "PermissionofRole"));
                item.Validation.Errors.Add(error);
                _logger.Log("FATAL", "Delete Permission of Role", item, error.ErrorMessage);
                return(item);
            }
            _logger.Log("INFO", "Delete Permission of Role", item, "Successful.");
            return(item);
        }